test_class.declarator: sampleDataJmsMessageListener
test_class.modifier: @Autowired
      private
test_class.original_string: @Autowired
      private SampleDataJmsMessageListener sampleDataJmsMessageListener;
test_class.type: SampleDataJmsMessageListener
test_class.var_name: sampleDataJmsMessageListener
test_class.file: herd-code/herd-service/src/test/java/org/finra/herd/service/helper/SampleDataJmsMessageListenerTest.java
test_class.identifier: SampleDataJmsMessageListenerTest
test_class.superclass: extends AbstractServiceTest
test_case.body: @Test
      public void testControlListener()
      {
          configurationHelper = Mockito.mock(ConfigurationHelper.class);
  
          ReflectionTestUtils.setField(sampleDataJmsMessageListener, "configurationHelper", configurationHelper);
          MessageListenerContainer mockMessageListenerContainer = Mockito.mock(MessageListenerContainer.class);
  
          //The listener is not enabled
          when(configurationHelper.getProperty(ConfigurationValue.SAMPLE_DATA_JMS_LISTENER_ENABLED)).thenReturn("false");
          JmsListenerEndpointRegistry registry = ApplicationContextHolder.getApplicationContext()
              .getBean("org.springframework.jms.config.internalJmsListenerEndpointRegistry", JmsListenerEndpointRegistry.class);
          when(registry.getListenerContainer(HerdJmsDestinationResolver.SQS_DESTINATION_SAMPLE_DATA_QUEUE)).thenReturn(mockMessageListenerContainer);
          //the listener is not running, nothing happened
          when(mockMessageListenerContainer.isRunning()).thenReturn(false);
          sampleDataJmsMessageListener.controlSampleDataJmsMessageListener();
          verify(mockMessageListenerContainer, Mockito.times(0)).stop();
          verify(mockMessageListenerContainer, Mockito.times(0)).start();
          // the listener is running, but it is not enable, should stop
          when(mockMessageListenerContainer.isRunning()).thenReturn(true);
          sampleDataJmsMessageListener.controlSampleDataJmsMessageListener();
          verify(mockMessageListenerContainer).stop();
  
          //The listener is enabled
          when(configurationHelper.getProperty(ConfigurationValue.SAMPLE_DATA_JMS_LISTENER_ENABLED)).thenReturn("true");
          //the listener is running, should not call the start method
          when(mockMessageListenerContainer.isRunning()).thenReturn(true);
          sampleDataJmsMessageListener.controlSampleDataJmsMessageListener();
          verify(mockMessageListenerContainer, Mockito.times(0)).start();
          // the listener is not running, but it is enabled, should start        
          when(mockMessageListenerContainer.isRunning()).thenReturn(false);
          sampleDataJmsMessageListener.controlSampleDataJmsMessageListener();
          verify(mockMessageListenerContainer).start();
      }
test_case.class_method_signature: SampleDataJmsMessageListenerTest.testControlListener()
test_case.full_signature: @Test public void testControlListener()
test_case.identifier: testControlListener
test_case.invocations: mock setField mock thenReturn when getProperty getBean getApplicationContext thenReturn when getListenerContainer thenReturn when isRunning controlSampleDataJmsMessageListener stop verify times start verify times thenReturn when isRunning controlSampleDataJmsMessageListener stop verify thenReturn when getProperty thenReturn when isRunning controlSampleDataJmsMessageListener start verify times thenReturn when isRunning controlSampleDataJmsMessageListener start verify
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testControlListener()
focal_class.declarator: LOGGER = LoggerFactory.getLogger(SampleDataJmsMessageListener.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = LoggerFactory.getLogger(SampleDataJmsMessageListener.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.declarator: configurationHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private ConfigurationHelper configurationHelper;
focal_class.type: ConfigurationHelper
focal_class.var_name: configurationHelper
focal_class.declarator: businessObjectDefinitionService
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private BusinessObjectDefinitionService businessObjectDefinitionService;
focal_class.type: BusinessObjectDefinitionService
focal_class.var_name: businessObjectDefinitionService
focal_class.file: herd-code/herd-service/src/main/java/org/finra/herd/service/helper/SampleDataJmsMessageListener.java
focal_class.identifier: SampleDataJmsMessageListener
focal_class.class_method_signature: SampleDataJmsMessageListener.controlSampleDataJmsMessageListener()
focal_class.full_signature: @Scheduled(fixedDelay = 60000) public void controlSampleDataJmsMessageListener()
focal_class.identifier: controlSampleDataJmsMessageListener
focal_class.modifiers: @Scheduled(fixedDelay = 60000) public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void controlSampleDataJmsMessageListener()
focal_class.class_method_signature: SampleDataJmsMessageListener.processMessage(String payload, @Headers Map<Object, Object> allHeaders)
focal_class.full_signature: @JmsListener(id = HerdJmsDestinationResolver.SQS_DESTINATION_SAMPLE_DATA_QUEUE, containerFactory = "jmsListenerContainerFactory", destination = HerdJmsDestinationResolver.SQS_DESTINATION_SAMPLE_DATA_QUEUE) public void processMessage(String payload, @Headers Map<Object, Object> allHeaders)
focal_class.identifier: processMessage
focal_class.modifiers: @JmsListener(id = HerdJmsDestinationResolver.SQS_DESTINATION_SAMPLE_DATA_QUEUE, containerFactory = "jmsListenerContainerFactory", destination = HerdJmsDestinationResolver.SQS_DESTINATION_SAMPLE_DATA_QUEUE) public
focal_class.parameters: (String payload, @Headers Map<Object, Object> allHeaders)
focal_class.return: void
focal_class.signature: void processMessage(String payload, @Headers Map<Object, Object> allHeaders)
focal_class.class_method_signature: SampleDataJmsMessageListener.convertS3KeyFormat(String string)
focal_class.full_signature: private String convertS3KeyFormat(String string)
focal_class.identifier: convertS3KeyFormat
focal_class.modifiers: private
focal_class.parameters: (String string)
focal_class.return: String
focal_class.signature: String convertS3KeyFormat(String string)
focal_method.body: @Scheduled(fixedDelay = 60000)
      public void controlSampleDataJmsMessageListener()
      {
          try
          {
              // Get the configuration setting.
              Boolean jmsMessageListenerEnabled =
                  Boolean.valueOf(configurationHelper.getProperty(ConfigurationValue.SAMPLE_DATA_JMS_LISTENER_ENABLED));
  
              // Get the registry bean.
              JmsListenerEndpointRegistry registry = ApplicationContextHolder.getApplicationContext()
                  .getBean("org.springframework.jms.config.internalJmsListenerEndpointRegistry", JmsListenerEndpointRegistry.class);
  
              // Get the sample data JMS message listener container.
              MessageListenerContainer jmsMessageListenerContainer =
                  registry.getListenerContainer(HerdJmsDestinationResolver.SQS_DESTINATION_SAMPLE_DATA_QUEUE);
  
              // Get the current JMS message listener status and the configuration value.
              LOGGER.debug("controlStoragePolicyProcessorJmsMessageListener(): {}={} jmsMessageListenerContainer.isRunning()={}",
                  ConfigurationValue.SAMPLE_DATA_JMS_LISTENER_ENABLED.getKey(), jmsMessageListenerEnabled, jmsMessageListenerContainer.isRunning());
  
              // Apply the relative action if needed.
              if (!jmsMessageListenerEnabled && jmsMessageListenerContainer.isRunning())
              {
                  LOGGER.info("controlSampleDataJmsMessageListener(): Stopping the sample data JMS message listener ...");
                  jmsMessageListenerContainer.stop();
                  LOGGER.info("controlSampleDataJmsMessageListener(): Done");
              }
              else if (jmsMessageListenerEnabled && !jmsMessageListenerContainer.isRunning())
              {
                  LOGGER.info("controlSampleDataJmsMessageListener(): Starting the sample data JMS message listener ...");
                  jmsMessageListenerContainer.start();
                  LOGGER.info("controlSampleDataJmsMessageListener(): Done");
              }
          }
          catch (Exception e)
          {
              LOGGER.error("controlSampleDataJmsMessageListener(): Failed to control the sample data Jms message listener service.", e);
          }
      }
focal_method.class_method_signature: SampleDataJmsMessageListener.controlSampleDataJmsMessageListener()
focal_method.full_signature: @Scheduled(fixedDelay = 60000) public void controlSampleDataJmsMessageListener()
focal_method.identifier: controlSampleDataJmsMessageListener
focal_method.invocations: valueOf getProperty getBean getApplicationContext getListenerContainer debug getKey isRunning isRunning info stop info isRunning info start info error
focal_method.modifiers: @Scheduled(fixedDelay = 60000) public
focal_method.parameters: ()
focal_method.return: void
focal_method.signature: void controlSampleDataJmsMessageListener()