@Test public void shouldReturnIdForTheGivenCode() { when(programMapper.getIdForCode("ABC")).thenReturn(10L); assertThat(programRepository.getIdByCode("ABC"), is(10L)); }
public Long getIdByCode(String code) { Long programId = mapper.getIdForCode(code); if (programId == null) { throw new DataException(new OpenLmisMessage(PROGRAM_CODE_INVALID)); } return programId; }
ProgramRepository { public Long getIdByCode(String code) { Long programId = mapper.getIdForCode(code); if (programId == null) { throw new DataException(new OpenLmisMessage(PROGRAM_CODE_INVALID)); } return programId; } }
ProgramRepository { public Long getIdByCode(String code) { Long programId = mapper.getIdForCode(code); if (programId == null) { throw new DataException(new OpenLmisMessage(PROGRAM_CODE_INVALID)); } return programId; } @Autowired  ProgramRepository(ProgramMapper programMapper); }
ProgramRepository { public Long getIdByCode(String code) { Long programId = mapper.getIdForCode(code); if (programId == null) { throw new DataException(new OpenLmisMessage(PROGRAM_CODE_INVALID)); } return programId; } @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 Long getIdByCode(String code) { Long programId = mapper.getIdForCode(code); if (programId == null) { throw new DataException(new OpenLmisMessage(PROGRAM_CODE_INVALID)); } return programId; } @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; }