TriggerEventServiceImpl implements TriggerEventService { @Override public long countDynamicTriggers(String moduleName) { return dynamicChannelLoader.countByChannelModuleName(moduleName); }  @Override @Transactional List<TriggerEvent> getDynamicTriggers(String moduleName, int page, int pareSize); @Override @Transactional List<TriggerEvent> getStaticTriggers(String moduleName, int page, int pageSize); @Override @Transactional TriggerEvent getTrigger(TaskTriggerInformation triggerInformation); @Override @Transactional boolean triggerExists(TaskTriggerInformation information); @Override boolean providesDynamicTriggers(String moduleName); @Override @Transactional long countStaticTriggers(String moduleName); @Override long countDynamicTriggers(String moduleName); @Override @Transactional Set<TaskError> validateTrigger(TaskTriggerInformation trigger); @Autowired void setTriggerEventsDataService(TriggerEventsDataService triggerEventsDataService); @Autowired void setChannelsDataService(ChannelsDataService channelsDataService); @Autowired void setDynamicChannelLoader(DynamicChannelLoader dynamicChannelLoader);  }
@Test public void shouldCountDynamicTriggers() throws Exception { long expectedCount = 1992; when(dynamicChannelLoader.countByChannelModuleName(MODULE_NAME)).thenReturn(expectedCount); long count = triggerEventService.countDynamicTriggers(MODULE_NAME); verify(dynamicChannelLoader, times(1)).countByChannelModuleName(MODULE_NAME); assertEquals(expectedCount, count); }