@Test
  public void shouldGetAllFacilitiesByName() {
    final String facilityName = "name";
    final String country = "country";
    final String region = "region";
    final String district = "district";
    final String province = "province";
    final String phoneNumber = "0123456789";
    final String mrsFacilityId = "12";

    final MRSFacility mrsFacility =
        new MRSFacility(mrsFacilityId, facilityName, country, region, district, province);
    Facility facility = new Facility(mrsFacility).phoneNumber(phoneNumber);

    when(mockMrsFacilityAdaptor.saveFacility(mrsFacility))
        .thenReturn(
            new MRSFacility(
                mrsFacilityId, facilityName, "country", "region", "district", "province"));
    allFacilities.add(facility);
    when(mockMrsFacilityAdaptor.getFacilities(facilityName)).thenReturn(Arrays.asList(mrsFacility));

    final List<Facility> actualFacilities = allFacilities.facilitiesByName(facilityName);

    final Facility actualFacility = actualFacilities.iterator().next();
    assertFacility(
        actualFacility, mrsFacilityId, facilityName, country, region, district, province);
    assertThat(actualFacility.phoneNumber(), is(equalTo(phoneNumber)));
  }
  @Test
  public void shouldReturnListOfFacilitiesByNameEvenIfTheRecordsAreMissingInCouchDb() {
    final String facilityName = "name";
    final String country = "country";
    final String region = "region";
    final String district = "district";
    final String province = "province";
    final String mrsFacilityId = "13";

    final MRSFacility mrsFacility =
        new MRSFacility(mrsFacilityId, facilityName, country, region, district, province);
    when(mockMrsFacilityAdaptor.getFacilities(facilityName)).thenReturn(Arrays.asList(mrsFacility));

    final List<Facility> actualFacilities = allFacilities.facilitiesByName(facilityName);

    final Facility actualFacility = actualFacilities.iterator().next();
    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)));
  }