@Test public void shouldThrowErrorIfFacilityMappedForSameProgramToDifferentDeliveryZones() throws Exception { when(deliveryZoneProgramScheduleService.getProgramIdsForDeliveryZones(member.getDeliveryZone().getId())).thenReturn(Arrays.asList(new Long[]{1L})); when(repository.getDeliveryZoneProgramIdsForFacility(member.getFacility().getId())).thenReturn(Arrays.asList(new Long[]{1L})); expectedException.expect(DataException.class); expectedException.expectMessage("facility.exists.for.program.in.multiple.zones"); service.save(member); }
public void save(DeliveryZoneMember member) { fillFacility(member); fillDeliveryZone(member); if (member.getId() == null) { validateIfFacilityAlreadyAssignedToDeliveryZoneForProgram(member); repository.insert(member); } else repository.update(member); }
DeliveryZoneMemberService { public void save(DeliveryZoneMember member) { fillFacility(member); fillDeliveryZone(member); if (member.getId() == null) { validateIfFacilityAlreadyAssignedToDeliveryZoneForProgram(member); repository.insert(member); } else repository.update(member); } }
DeliveryZoneMemberService { public void save(DeliveryZoneMember member) { fillFacility(member); fillDeliveryZone(member); if (member.getId() == null) { validateIfFacilityAlreadyAssignedToDeliveryZoneForProgram(member); repository.insert(member); } else repository.update(member); }  }
DeliveryZoneMemberService { public void save(DeliveryZoneMember member) { fillFacility(member); fillDeliveryZone(member); if (member.getId() == null) { validateIfFacilityAlreadyAssignedToDeliveryZoneForProgram(member); repository.insert(member); } else repository.update(member); }  void save(DeliveryZoneMember member); DeliveryZoneMember getByDeliveryZoneCodeAndFacilityCode(String deliveryZoneCode, String facilityCode); }
DeliveryZoneMemberService { public void save(DeliveryZoneMember member) { fillFacility(member); fillDeliveryZone(member); if (member.getId() == null) { validateIfFacilityAlreadyAssignedToDeliveryZoneForProgram(member); repository.insert(member); } else repository.update(member); }  void save(DeliveryZoneMember member); DeliveryZoneMember getByDeliveryZoneCodeAndFacilityCode(String deliveryZoneCode, String facilityCode);  }