コード例 #1
0
  @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)));
  }
コード例 #2
0
  @Test
  public void shouldUpdateFacility() {
    final String facilityId = "16";
    final String facilityName = "name";
    final String phoneNumber = "0123456789";
    String additionalPhone1 = "12345";
    String additionalPhone2 = "321234";
    String additionalPhone3 = "33344";

    final String updatedFacilityName = "name";
    final String updatedPhoneNumber = "0123456789";
    String updatedAdditionalPhone1 = "12345";
    String updatedAdditionalPhone2 = "321234";
    String updatedAdditionalPhone3 = "33344";

    final MRSFacility mrsFacility = new MRSFacility(facilityName);
    Facility facility =
        facility(phoneNumber, additionalPhone1, additionalPhone2, additionalPhone3, mrsFacility);

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

    final MRSFacility updatedMRSFacility = new MRSFacility(updatedFacilityName);
    facility
        .phoneNumber(updatedPhoneNumber)
        .additionalPhoneNumber1(updatedAdditionalPhone1)
        .additionalPhoneNumber2(updatedAdditionalPhone2)
        .additionalPhoneNumber3(updatedAdditionalPhone3)
        .mrsFacility(updatedMRSFacility);

    allFacilities.update(facility);
  }
コード例 #3
0
  @Test
  public void shouldSaveAFacility() throws Exception {
    final String facilityName = "name";
    final String phoneNumber = "0123456789";
    String additionalPhone1 = "12345";
    String additionalPhone2 = "321234";
    String additionalPhone3 = "33344";
    final MRSFacility mrsFacility = new MRSFacility(facilityName);
    Facility facility =
        facility(phoneNumber, additionalPhone1, additionalPhone2, additionalPhone3, mrsFacility);
    final int initialSize = allFacilities.getAll().size();

    final String facilityId = "12";
    when(mockMrsFacilityAdaptor.saveFacility(mrsFacility))
        .thenReturn(
            new MRSFacility(facilityId, facilityName, "country", "region", "district", "province"));

    allFacilities.add(facility);

    final List<Facility> facilities = allFacilities.getAll();
    final int actualSize = facilities.size();
    final Facility actualFacility = facilities.iterator().next();
    assertThat(actualSize, is(equalTo(initialSize + 1)));
    assertThat(actualFacility.phoneNumber(), is(equalTo(phoneNumber)));
    assertThat(actualFacility.additionalPhoneNumber1(), is(equalTo(additionalPhone1)));
    assertThat(actualFacility.additionalPhoneNumber2(), is(equalTo(additionalPhone2)));
    assertThat(actualFacility.additionalPhoneNumber3(), is(equalTo(additionalPhone3)));
    assertThat(actualFacility.mrsFacilityId(), is(equalTo(facilityId)));
  }
コード例 #4
0
  @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)));
  }