@Test public void shouldGetSupportedProgramsForFacilityForAUserForGivenRights() throws Exception { List<Program> expectedPrograms = new ArrayList<>(); when(programMapper.getProgramsForUserByFacilityAndRights(1L, 1L, "{AUTHORIZE_REQUISITION, VIEW_REQUISITION}")).thenReturn(expectedPrograms); List<Program> programs = programRepository.getProgramsForUserByFacilityAndRights(1L, 1L, AUTHORIZE_REQUISITION, VIEW_REQUISITION); assertThat(programs, is(expectedPrograms)); verify(programMapper, times(1)).getProgramsForUserByFacilityAndRights(1L, 1L, "{AUTHORIZE_REQUISITION, VIEW_REQUISITION}"); }
public List<Program> getProgramsForUserByFacilityAndRights(Long facilityId, Long userId, String... rightNames) { return mapper.getProgramsForUserByFacilityAndRights(facilityId, userId, commaSeparateRightNames(rightNames)); }
ProgramRepository { public List<Program> getProgramsForUserByFacilityAndRights(Long facilityId, Long userId, String... rightNames) { return mapper.getProgramsForUserByFacilityAndRights(facilityId, userId, commaSeparateRightNames(rightNames)); } }
ProgramRepository { public List<Program> getProgramsForUserByFacilityAndRights(Long facilityId, Long userId, String... rightNames) { return mapper.getProgramsForUserByFacilityAndRights(facilityId, userId, commaSeparateRightNames(rightNames)); } @Autowired  ProgramRepository(ProgramMapper programMapper); }
ProgramRepository { public List<Program> getProgramsForUserByFacilityAndRights(Long facilityId, Long userId, String... rightNames) { return mapper.getProgramsForUserByFacilityAndRights(facilityId, userId, commaSeparateRightNames(rightNames)); } @Autowired  ProgramRepository(ProgramMapper programMapper); void insert(Program p); Program update(Program program); List<Program> getByFacility(Long facilityId); List<Program> getAllPullPrograms(); List<Program> getAllPushPrograms(); List<Program> getUserSupervisedActiveProgramsWithRights(Long userId, String... rightNames); List<Program> getUserSupervisedActiveIvdProgramsWithRights(Long userId, String... rightNames); List<Program> getProgramsSupportedByUserHomeFacilityWithRights(Long facilityId, Long userId, String... rightNames); List<Program> getIvdProgramsSupportedByUserHomeFacilityWithRights(Long facilityId, Long userId, String... rightNames); Long getIdByCode(String code); List<Program> getActiveProgramsForUserWithRights(Long userId, String... rightNames); 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); List<Program> getProgramsForNotification(); List<Program> getAllIvdPrograms(); }
ProgramRepository { public List<Program> getProgramsForUserByFacilityAndRights(Long facilityId, Long userId, String... rightNames) { return mapper.getProgramsForUserByFacilityAndRights(facilityId, userId, commaSeparateRightNames(rightNames)); } @Autowired  ProgramRepository(ProgramMapper programMapper); void insert(Program p); Program update(Program program); List<Program> getByFacility(Long facilityId); List<Program> getAllPullPrograms(); List<Program> getAllPushPrograms(); List<Program> getUserSupervisedActiveProgramsWithRights(Long userId, String... rightNames); List<Program> getUserSupervisedActiveIvdProgramsWithRights(Long userId, String... rightNames); List<Program> getProgramsSupportedByUserHomeFacilityWithRights(Long facilityId, Long userId, String... rightNames); List<Program> getIvdProgramsSupportedByUserHomeFacilityWithRights(Long facilityId, Long userId, String... rightNames); Long getIdByCode(String code); List<Program> getActiveProgramsForUserWithRights(Long userId, String... rightNames); 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); List<Program> getProgramsForNotification(); List<Program> getAllIvdPrograms(); static String PROGRAM_CODE_INVALID; }