@Test public void shouldFetchFacilitiesGivenAListOfMRSFacilityIds() { final MRSFacility anyFacility1 = new MRSFacility("1", "name", "country", "region", "district", "province"); final MRSFacility anyFacility2 = new MRSFacility("2", "name", "country", "region", "district", "province"); final MRSFacility anyFacility3 = new MRSFacility("3", "name", "country", "region", "district", "province"); final MRSFacility anyFacility4 = new MRSFacility("4", "name", "country", "region", "district", "province"); final Facility facility1 = new Facility(new MRSFacility("1", "name1", "country", "region", "district", "province")); final Facility facility2 = new Facility(new MRSFacility("2", "name2", "country", "region", "district", "province")); final Facility facility3 = new Facility(new MRSFacility("3", "name3", "country", "region", "district", "province")); final Facility facility4 = new Facility(new MRSFacility("4", "name4", "country", "region", "district", "province")); when(mockMrsFacilityAdaptor.saveFacility(facility1.mrsFacility())).thenReturn(anyFacility1); when(mockMrsFacilityAdaptor.saveFacility(facility2.mrsFacility())).thenReturn(anyFacility2); when(mockMrsFacilityAdaptor.saveFacility(facility3.mrsFacility())).thenReturn(anyFacility3); when(mockMrsFacilityAdaptor.saveFacility(facility4.mrsFacility())).thenReturn(anyFacility4); allFacilities.add(facility1); allFacilities.add(facility2); allFacilities.add(facility3); allFacilities.add(facility4); final List<Facility> byFacilityIds = allFacilities.findByFacilityIds(Arrays.asList("1", "2")); assertThat(byFacilityIds.size(), is(2)); }
private void assertFacility( Facility actualFacility, String facilityId, String facilityName, String country, String region, String district, String province) { assertThat(actualFacility.name(), is(equalTo(facilityName))); assertThat(actualFacility.country(), is(equalTo(country))); assertThat(actualFacility.region(), is(equalTo(region))); assertThat(actualFacility.province(), is(equalTo(province))); assertThat(actualFacility.district(), is(equalTo(district))); assertThat(actualFacility.mrsFacility().getId(), is(equalTo(facilityId))); }
@Test public void shouldGetFacilityByMotechFacilityId() { AllFacilities allFacilitiesSpy = spy(allFacilities); String motechFacilityId = "10000"; String mrsFacilityId = "10"; String phone_number = "0123456789"; Facility motechFacility = facility(phone_number, null, null, null, null) .mrsFacilityId(mrsFacilityId) .motechId(motechFacilityId); MRSFacility mrsFacility = mock(MRSFacility.class); doReturn(motechFacility).when(allFacilitiesSpy).findByMotechFacilityId(motechFacilityId); when(mockMrsFacilityAdaptor.getFacility(mrsFacilityId)).thenReturn(mrsFacility); Facility returnedFacility = allFacilitiesSpy.getFacilityByMotechId(motechFacilityId); assertThat(returnedFacility.motechId(), is(equalTo(motechFacilityId))); assertThat(returnedFacility.mrsFacilityId(), is(equalTo(mrsFacilityId))); assertThat(returnedFacility.phoneNumber(), is(equalTo(phone_number))); assertThat(returnedFacility.mrsFacility(), is(equalTo(mrsFacility))); }