@Test public void shouldInsertRequisitionGroupMembers() throws Exception { RequisitionGroupMember member = new RequisitionGroupMember(); Facility facility = new Facility(); facility.setId(1L); member.setFacility(facility); member.setId(1L); member.getFacility().setCode("code"); RequisitionGroupMemberService serviceSpy = PowerMockito.spy(service); PowerMockito.doNothing().when(serviceSpy, method(RequisitionGroupMemberService.class, "validateIfFacilityIsAlreadyAssignedToRequisitionGroupForProgram", RequisitionGroupMember.class)).withArguments(member); serviceSpy.insert(member); verify(facilityRepository).getIdForCode(member.getFacility().getCode()); verify(requisitionGroupMemberRepository).insert(member); }
public void insert(RequisitionGroupMember member) { Long facilityId = facilityRepository.getIdForCode(member.getFacility().getCode()); member.getFacility().setId(facilityId); validateIfFacilityIsAlreadyAssignedToRequisitionGroupForProgram(member); requisitionGroupMemberRepository.insert(member); }
RequisitionGroupMemberService { public void insert(RequisitionGroupMember member) { Long facilityId = facilityRepository.getIdForCode(member.getFacility().getCode()); member.getFacility().setId(facilityId); validateIfFacilityIsAlreadyAssignedToRequisitionGroupForProgram(member); requisitionGroupMemberRepository.insert(member); } }
RequisitionGroupMemberService { public void insert(RequisitionGroupMember member) { Long facilityId = facilityRepository.getIdForCode(member.getFacility().getCode()); member.getFacility().setId(facilityId); validateIfFacilityIsAlreadyAssignedToRequisitionGroupForProgram(member); requisitionGroupMemberRepository.insert(member); } @Autowired  RequisitionGroupMemberService(RequisitionGroupMemberRepository requisitionGroupMemberRepository,
                                       FacilityRepository facilityRepository, RequisitionGroupRepository requisitionGroupRepository,
                                       RequisitionGroupProgramScheduleRepository requisitionGroupProgramScheduleRepository,
                                       ProgramRepository programRepository); }
RequisitionGroupMemberService { public void insert(RequisitionGroupMember member) { Long facilityId = facilityRepository.getIdForCode(member.getFacility().getCode()); member.getFacility().setId(facilityId); validateIfFacilityIsAlreadyAssignedToRequisitionGroupForProgram(member); requisitionGroupMemberRepository.insert(member); } @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 insert(RequisitionGroupMember member) { Long facilityId = facilityRepository.getIdForCode(member.getFacility().getCode()); member.getFacility().setId(facilityId); validateIfFacilityIsAlreadyAssignedToRequisitionGroupForProgram(member); requisitionGroupMemberRepository.insert(member); } @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);  }