@Test public void shouldNotRegisterHandler() { EventListenerRegistryService eventListenerRegistryService = mock(EventListenerRegistryService.class); when(taskService.getAllTasks()).thenReturn(new ArrayList<>()); handler.init(); verify(eventListenerRegistryService, never()).registerListener(any(EventListener.class), anyString()); }
@PostConstruct public void init() { for (Task task : taskService.getAllTasks()) { registerHandlerFor(task.getTrigger().getEffectiveListenerSubject()); if (task.isRetryTaskOnFailure()) { registerHandlerFor(task.getTrigger().getEffectiveListenerRetrySubject(), true); } } }
TaskTriggerHandler implements TriggerHandler { @PostConstruct public void init() { for (Task task : taskService.getAllTasks()) { registerHandlerFor(task.getTrigger().getEffectiveListenerSubject()); if (task.isRetryTaskOnFailure()) { registerHandlerFor(task.getTrigger().getEffectiveListenerRetrySubject(), true); } } } }
TaskTriggerHandler implements TriggerHandler { @PostConstruct public void init() { for (Task task : taskService.getAllTasks()) { registerHandlerFor(task.getTrigger().getEffectiveListenerSubject()); if (task.isRetryTaskOnFailure()) { registerHandlerFor(task.getTrigger().getEffectiveListenerRetrySubject(), true); } } }  }
TaskTriggerHandler implements TriggerHandler { @PostConstruct public void init() { for (Task task : taskService.getAllTasks()) { registerHandlerFor(task.getTrigger().getEffectiveListenerSubject()); if (task.isRetryTaskOnFailure()) { registerHandlerFor(task.getTrigger().getEffectiveListenerRetrySubject(), true); } } }  @PostConstruct void init(); @PreDestroy void preDestroy(); @Override void registerHandlerFor(String subject); @Override void registerHandlerFor(String subject, boolean isRetryHandler); @Override @Transactional void handle(MotechEvent event); @Override @Transactional void handleRetry(MotechEvent event); @Override @Transactional void retryTask(Long activityId); @Override void addDataProvider(DataProvider provider); @Override void removeDataProvider(String taskDataProviderId); @Autowired void setBundleContext(BundleContext bundleContext); }
TaskTriggerHandler implements TriggerHandler { @PostConstruct public void init() { for (Task task : taskService.getAllTasks()) { registerHandlerFor(task.getTrigger().getEffectiveListenerSubject()); if (task.isRetryTaskOnFailure()) { registerHandlerFor(task.getTrigger().getEffectiveListenerRetrySubject(), true); } } }  @PostConstruct void init(); @PreDestroy void preDestroy(); @Override void registerHandlerFor(String subject); @Override void registerHandlerFor(String subject, boolean isRetryHandler); @Override @Transactional void handle(MotechEvent event); @Override @Transactional void handleRetry(MotechEvent event); @Override @Transactional void retryTask(Long activityId); @Override void addDataProvider(DataProvider provider); @Override void removeDataProvider(String taskDataProviderId); @Autowired void setBundleContext(BundleContext bundleContext);  }