TrackerNotificationMessageManager extends BaseMessageManager { @JmsListener( destination = Topics.TRACKER_IMPORT_NOTIFICATION_TOPIC_NAME, containerFactory = "jmsQueueListenerContainerFactory" ) public void consume( TextMessage message ) throws JMSException, IOException { TrackerSideEffectDataBundle bundle = toBundle( message ); if ( bundle == null ) { return; } JobConfiguration jobConfiguration = new JobConfiguration( "", JobType.TRACKER_IMPORT_NOTIFICATION_JOB, bundle.getAccessedBy(), true ); bundle.setJobConfiguration( jobConfiguration ); TrackerNotificationThread notificationThread = trackerNotificationThreadObjectFactory.getObject(); notificationThread.setSideEffectDataBundle( bundle ); executeJob( notificationThread ); } TrackerNotificationMessageManager(
        MessageManager messageManager,
        SchedulingManager schedulingManager,
        RenderService renderService,
        ObjectFactory<TrackerNotificationThread> trackerNotificationThreadObjectFactory ); @Override String getTopic(); @JmsListener( destination = Topics.TRACKER_IMPORT_NOTIFICATION_TOPIC_NAME, containerFactory = "jmsQueueListenerContainerFactory" ) void consume( TextMessage message );  }
@Test public void test_message_consumer() throws JMSException, IOException { TrackerSideEffectDataBundle bundle = TrackerSideEffectDataBundle.builder().accessedBy( "test-user" ).build(); when( textMessage.getText() ).thenReturn( "text" ); when( objectFactory.getObject() ).thenReturn( trackerNotificationThread ); doNothing().when( schedulingManager ).executeJob( any( Runnable.class ) ); when( renderService.fromJson( anyString(), eq( TrackerSideEffectDataBundle.class ) ) ).thenReturn( null ); trackerNotificationMessageManager.consume( textMessage ); verify( schedulingManager, times( 0 ) ).executeJob( any( Runnable.class ) ); doReturn( bundle ).when( renderService ).fromJson( anyString(), eq( TrackerSideEffectDataBundle.class ) ); trackerNotificationMessageManager.consume( textMessage ); Mockito.verify( schedulingManager ).executeJob( runnableCaptor.capture() ); assertTrue( runnableCaptor.getValue() instanceof TrackerNotificationThread ); }