@Test public void shouldGiveErrorIfRequisitionGroupCodeDoesNotExist() throws Exception { when(requisitionGroupMapper.getIdForCode(requisitionGroupProgramSchedule.getRequisitionGroup().getCode())).thenReturn(null); expectedEx.expect(dataExceptionMatcher("error.requisition.group.not.exists")); repository.insert(requisitionGroupProgramSchedule); verify(requisitionGroupMapper).getIdForCode(requisitionGroupProgramSchedule.getRequisitionGroup().getCode()); verify(requisitionGroupProgramScheduleMapper, never()).insert(requisitionGroupProgramSchedule); }
public void insert(RequisitionGroupProgramSchedule requisitionGroupProgramSchedule) { populateIdsForRequisitionProgramScheduleEntities(requisitionGroupProgramSchedule); validateRequisitionGroupSchedule(requisitionGroupProgramSchedule); validateProgramType(requisitionGroupProgramSchedule); try { mapper.insert(requisitionGroupProgramSchedule); } catch (DuplicateKeyException e) { throw new DataException("error.duplicate.requisition.group.program.combination"); } }
RequisitionGroupProgramScheduleRepository { public void insert(RequisitionGroupProgramSchedule requisitionGroupProgramSchedule) { populateIdsForRequisitionProgramScheduleEntities(requisitionGroupProgramSchedule); validateRequisitionGroupSchedule(requisitionGroupProgramSchedule); validateProgramType(requisitionGroupProgramSchedule); try { mapper.insert(requisitionGroupProgramSchedule); } catch (DuplicateKeyException e) { throw new DataException("error.duplicate.requisition.group.program.combination"); } } }
RequisitionGroupProgramScheduleRepository { public void insert(RequisitionGroupProgramSchedule requisitionGroupProgramSchedule) { populateIdsForRequisitionProgramScheduleEntities(requisitionGroupProgramSchedule); validateRequisitionGroupSchedule(requisitionGroupProgramSchedule); validateProgramType(requisitionGroupProgramSchedule); try { mapper.insert(requisitionGroupProgramSchedule); } catch (DuplicateKeyException e) { throw new DataException("error.duplicate.requisition.group.program.combination"); } } @Autowired  RequisitionGroupProgramScheduleRepository(
    RequisitionGroupProgramScheduleMapper requisitionGroupProgramScheduleMapper,
    RequisitionGroupMapper requisitionGroupMapper,
    ProgramRepository programRepository,
    ProcessingScheduleMapper processingScheduleMapper,
    FacilityMapper facilityMapper); }
RequisitionGroupProgramScheduleRepository { public void insert(RequisitionGroupProgramSchedule requisitionGroupProgramSchedule) { populateIdsForRequisitionProgramScheduleEntities(requisitionGroupProgramSchedule); validateRequisitionGroupSchedule(requisitionGroupProgramSchedule); validateProgramType(requisitionGroupProgramSchedule); try { mapper.insert(requisitionGroupProgramSchedule); } catch (DuplicateKeyException e) { throw new DataException("error.duplicate.requisition.group.program.combination"); } } @Autowired  RequisitionGroupProgramScheduleRepository(
    RequisitionGroupProgramScheduleMapper requisitionGroupProgramScheduleMapper,
    RequisitionGroupMapper requisitionGroupMapper,
    ProgramRepository programRepository,
    ProcessingScheduleMapper processingScheduleMapper,
    FacilityMapper facilityMapper); void insert(RequisitionGroupProgramSchedule requisitionGroupProgramSchedule); void update(RequisitionGroupProgramSchedule requisitionGroupProgramSchedule); RequisitionGroupProgramSchedule getScheduleForRequisitionGroupAndProgram(Long requisitionGroupId, Long programId); List<Long> getProgramIDsForRequisitionGroup(Long requisitionGroupId); RequisitionGroupProgramSchedule getScheduleForRequisitionGroupCodeAndProgramCode(String requisitionGroupCode, String programCode); List<RequisitionGroupProgramSchedule> getByRequisitionGroupId(Long requisitionGroupId); void deleteRequisitionGroupProgramSchedulesFor(Long requisitionGroupId); }
RequisitionGroupProgramScheduleRepository { public void insert(RequisitionGroupProgramSchedule requisitionGroupProgramSchedule) { populateIdsForRequisitionProgramScheduleEntities(requisitionGroupProgramSchedule); validateRequisitionGroupSchedule(requisitionGroupProgramSchedule); validateProgramType(requisitionGroupProgramSchedule); try { mapper.insert(requisitionGroupProgramSchedule); } catch (DuplicateKeyException e) { throw new DataException("error.duplicate.requisition.group.program.combination"); } } @Autowired  RequisitionGroupProgramScheduleRepository(
    RequisitionGroupProgramScheduleMapper requisitionGroupProgramScheduleMapper,
    RequisitionGroupMapper requisitionGroupMapper,
    ProgramRepository programRepository,
    ProcessingScheduleMapper processingScheduleMapper,
    FacilityMapper facilityMapper); void insert(RequisitionGroupProgramSchedule requisitionGroupProgramSchedule); void update(RequisitionGroupProgramSchedule requisitionGroupProgramSchedule); RequisitionGroupProgramSchedule getScheduleForRequisitionGroupAndProgram(Long requisitionGroupId, Long programId); List<Long> getProgramIDsForRequisitionGroup(Long requisitionGroupId); RequisitionGroupProgramSchedule getScheduleForRequisitionGroupCodeAndProgramCode(String requisitionGroupCode, String programCode); List<RequisitionGroupProgramSchedule> getByRequisitionGroupId(Long requisitionGroupId); void deleteRequisitionGroupProgramSchedulesFor(Long requisitionGroupId);  }