@Test public void shouldGiveErrorIfNoProgramsMappedToRG() throws Exception { when(requisitionGroupRepository.getByCode(requisitionGroupMember.getRequisitionGroup())).thenReturn(requisitionGroup); when(facilityRepository.getIdForCode(requisitionGroupMember.getFacility().getCode())).thenReturn(FACILITY_ID); when(requisitionGroupProgramScheduleRepository.getProgramIDsForRequisitionGroup(RG_ID)).thenReturn(new ArrayList<Long>()); expectedEx.expect(DataException.class); expectedEx.expect(dataExceptionMatcher("error.no.program.mapped.requisition.group")); service.save(requisitionGroupMember); }
public void save(RequisitionGroupMember requisitionGroupMember) { setIdsForRequisitionGroupMemberEntitiesAndValidate(requisitionGroupMember); if (requisitionGroupMember.getId() == null) { validateIfFacilityIsAlreadyAssignedToRequisitionGroupForProgram(requisitionGroupMember); requisitionGroupMemberRepository.insert(requisitionGroupMember); } else { requisitionGroupMemberRepository.update(requisitionGroupMember); } }
RequisitionGroupMemberService { public void save(RequisitionGroupMember requisitionGroupMember) { setIdsForRequisitionGroupMemberEntitiesAndValidate(requisitionGroupMember); if (requisitionGroupMember.getId() == null) { validateIfFacilityIsAlreadyAssignedToRequisitionGroupForProgram(requisitionGroupMember); requisitionGroupMemberRepository.insert(requisitionGroupMember); } else { requisitionGroupMemberRepository.update(requisitionGroupMember); } } }
RequisitionGroupMemberService { public void save(RequisitionGroupMember requisitionGroupMember) { setIdsForRequisitionGroupMemberEntitiesAndValidate(requisitionGroupMember); if (requisitionGroupMember.getId() == null) { validateIfFacilityIsAlreadyAssignedToRequisitionGroupForProgram(requisitionGroupMember); requisitionGroupMemberRepository.insert(requisitionGroupMember); } else { requisitionGroupMemberRepository.update(requisitionGroupMember); } } @Autowired  RequisitionGroupMemberService(RequisitionGroupMemberRepository requisitionGroupMemberRepository,
                                       FacilityRepository facilityRepository, RequisitionGroupRepository requisitionGroupRepository,
                                       RequisitionGroupProgramScheduleRepository requisitionGroupProgramScheduleRepository,
                                       ProgramRepository programRepository); }
RequisitionGroupMemberService { public void save(RequisitionGroupMember requisitionGroupMember) { setIdsForRequisitionGroupMemberEntitiesAndValidate(requisitionGroupMember); if (requisitionGroupMember.getId() == null) { validateIfFacilityIsAlreadyAssignedToRequisitionGroupForProgram(requisitionGroupMember); requisitionGroupMemberRepository.insert(requisitionGroupMember); } else { requisitionGroupMemberRepository.update(requisitionGroupMember); } } @Autowired  RequisitionGroupMemberService(RequisitionGroupMemberRepository requisitionGroupMemberRepository,
                                       FacilityRepository facilityRepository, RequisitionGroupRepository requisitionGroupRepository,
                                       RequisitionGroupProgramScheduleRepository requisitionGroupProgramScheduleRepository,
                                       ProgramRepository programRepository); void save(RequisitionGroupMember requisitionGroupMember); void updateMembersForVirtualFacilities(Facility parentFacility); RequisitionGroupMember getExisting(RequisitionGroupMember record); void removeRequisitionGroupMember(RequisitionGroup requisitionGroup, Facility facility); List<RequisitionGroupMember> getAllRequisitionGroupMembersByFacility(Long facilityId); void deleteMembersFor(Facility facility); List<RequisitionGroupMember> getMembersBy(Long requisitionGroupId); void deleteMembersForGroup(Long requisitionGroupId); void insert(RequisitionGroupMember member); }
RequisitionGroupMemberService { public void save(RequisitionGroupMember requisitionGroupMember) { setIdsForRequisitionGroupMemberEntitiesAndValidate(requisitionGroupMember); if (requisitionGroupMember.getId() == null) { validateIfFacilityIsAlreadyAssignedToRequisitionGroupForProgram(requisitionGroupMember); requisitionGroupMemberRepository.insert(requisitionGroupMember); } else { requisitionGroupMemberRepository.update(requisitionGroupMember); } } @Autowired  RequisitionGroupMemberService(RequisitionGroupMemberRepository requisitionGroupMemberRepository,
                                       FacilityRepository facilityRepository, RequisitionGroupRepository requisitionGroupRepository,
                                       RequisitionGroupProgramScheduleRepository requisitionGroupProgramScheduleRepository,
                                       ProgramRepository programRepository); void save(RequisitionGroupMember requisitionGroupMember); void updateMembersForVirtualFacilities(Facility parentFacility); RequisitionGroupMember getExisting(RequisitionGroupMember record); void removeRequisitionGroupMember(RequisitionGroup requisitionGroup, Facility facility); List<RequisitionGroupMember> getAllRequisitionGroupMembersByFacility(Long facilityId); void deleteMembersFor(Facility facility); List<RequisitionGroupMember> getMembersBy(Long requisitionGroupId); void deleteMembersForGroup(Long requisitionGroupId); void insert(RequisitionGroupMember member);  }