@Test public void shouldNotifyProgramsForWhichFeedSendFlagIsSet() throws Exception { List<Program> programList = new ArrayList<Program>() {{ add(make(a(defaultProgram))); add(make(a(defaultProgram, with(programCode, "second program")))); }}; when(programRepository.getProgramsForNotification()).thenReturn(programList); service.notifyProgramChange(); verify(programRepository).getProgramsForNotification(); verify(eventService, times(2)).notify(any(ProgramChangeEvent.class)); }
public void notifyProgramChange() { List<Program> programsForNotifications = programRepository.getProgramsForNotification(); for (Program program : programsForNotifications) { try { eventService.notify(new ProgramChangeEvent(program)); programRepository.setFeedSendFlag(program, false); } catch (URISyntaxException e) { throw new DataException("error.malformed.uri"); } } }
ProgramService { public void notifyProgramChange() { List<Program> programsForNotifications = programRepository.getProgramsForNotification(); for (Program program : programsForNotifications) { try { eventService.notify(new ProgramChangeEvent(program)); programRepository.setFeedSendFlag(program, false); } catch (URISyntaxException e) { throw new DataException("error.malformed.uri"); } } } }
ProgramService { public void notifyProgramChange() { List<Program> programsForNotifications = programRepository.getProgramsForNotification(); for (Program program : programsForNotifications) { try { eventService.notify(new ProgramChangeEvent(program)); programRepository.setFeedSendFlag(program, false); } catch (URISyntaxException e) { throw new DataException("error.malformed.uri"); } } }  }
ProgramService { public void notifyProgramChange() { List<Program> programsForNotifications = programRepository.getProgramsForNotification(); for (Program program : programsForNotifications) { try { eventService.notify(new ProgramChangeEvent(program)); programRepository.setFeedSendFlag(program, false); } catch (URISyntaxException e) { throw new DataException("error.malformed.uri"); } } }  List<Program> getByFacility(Long facilityId); List<Program> getAllPullPrograms(); List<Program> getAllPushPrograms(); List<Program> getAllIvdPrograms(); List<Program> getProgramsSupportedByUserHomeFacilityWithRights(Long facilityId, Long userId, String... rightNames); List<Program> getIvdProgramsSupportedByUserHomeFacilityWithRights(Long facilityId, Long userId, String... rightNames); List<Program> getProgramForSupervisedFacilities(Long userId, String... rightNames); List<Program> getIvdProgramForSupervisedFacilities(Long userId, String... rightNames); Long getIdForCode(String code); Date getProgramStartDate(Long facilityId, Long programId); Program getById(Long id); void setTemplateConfigured(Long id); List<Program> getProgramsForUserByFacilityAndRights(Long facilityId, Long userId, String... rightNames); List<Program> getAll(); Program getByCode(String code); void setRegimenTemplateConfigured(Long programId); void setFeedSendFlag(Program program, Boolean sendFeed); void save(Program program); void notifyProgramChange(); Program getValidatedProgramByCode(String programCode); Program update(Program program); List<Program> getProgramsForUserByRights(Long userId, String rightName); }
ProgramService { public void notifyProgramChange() { List<Program> programsForNotifications = programRepository.getProgramsForNotification(); for (Program program : programsForNotifications) { try { eventService.notify(new ProgramChangeEvent(program)); programRepository.setFeedSendFlag(program, false); } catch (URISyntaxException e) { throw new DataException("error.malformed.uri"); } } }  List<Program> getByFacility(Long facilityId); List<Program> getAllPullPrograms(); List<Program> getAllPushPrograms(); List<Program> getAllIvdPrograms(); List<Program> getProgramsSupportedByUserHomeFacilityWithRights(Long facilityId, Long userId, String... rightNames); List<Program> getIvdProgramsSupportedByUserHomeFacilityWithRights(Long facilityId, Long userId, String... rightNames); List<Program> getProgramForSupervisedFacilities(Long userId, String... rightNames); List<Program> getIvdProgramForSupervisedFacilities(Long userId, String... rightNames); Long getIdForCode(String code); Date getProgramStartDate(Long facilityId, Long programId); Program getById(Long id); void setTemplateConfigured(Long id); List<Program> getProgramsForUserByFacilityAndRights(Long facilityId, Long userId, String... rightNames); List<Program> getAll(); Program getByCode(String code); void setRegimenTemplateConfigured(Long programId); void setFeedSendFlag(Program program, Boolean sendFeed); void save(Program program); void notifyProgramChange(); Program getValidatedProgramByCode(String programCode); Program update(Program program); List<Program> getProgramsForUserByRights(Long userId, String rightName);  }