Search in sources :

Example 1 with Metadata

use of com.smartystreets.api.us_street.Metadata in project API by ca-cwds.

the class SmartyStreetTest method successfulWithDpvY.

/*
   * Successful Tests
   */
@Test
public void successfulWithDpvY() throws Exception {
    ArrayList<Candidate> dpvY = new ArrayList<Candidate>();
    Candidate mockcandidate1 = mock(Candidate.class);
    Analysis mockanalysis1 = mock(Analysis.class);
    Components mockancomponents1 = mock(Components.class);
    Metadata mockanmetadata1 = mock(Metadata.class);
    Mockito.when(mockcandidate1.getDeliveryLine1()).thenReturn("106 Big Valley Rd");
    Mockito.when(mockcandidate1.getComponents()).thenReturn(mockancomponents1);
    Mockito.when(mockancomponents1.getCityName()).thenReturn("Folsom");
    Mockito.when(mockancomponents1.getState()).thenReturn("CA");
    Mockito.when(mockancomponents1.getZipCode()).thenReturn("95630");
    Mockito.when(mockcandidate1.getMetadata()).thenReturn(mockanmetadata1);
    Mockito.when(mockanmetadata1.getLongitude()).thenReturn(-121.13233);
    Mockito.when(mockanmetadata1.getLatitude()).thenReturn(38.64028);
    Mockito.when(mockcandidate1.getAnalysis()).thenReturn(mockanalysis1);
    Mockito.when(mockanalysis1.getDpvMatchCode()).thenReturn("Y");
    dpvY.add(mockcandidate1);
    String a = "106 Big Valley Rd";
    String b = "folsom";
    String c = "ca";
    Integer z = 0;
    Mockito.doReturn(dpvY).when(spySmartyStreet).getSmartyStreetsCandidates(a, b, c, z);
    ValidatedAddress[] actual = spySmartyStreet.usStreetSingleAddress(a, b, c, z);
    ValidatedAddress[] expected = new ValidatedAddress[1];
    expected[0] = new ValidatedAddress("106 Big Valley Rd", "Folsom", "CA", 95630, -121.13233, 38.64028, true);
    assertThat(actual[0], is(equalTo(expected[0])));
}
Also used : Candidate(com.smartystreets.api.us_street.Candidate) Components(com.smartystreets.api.us_street.Components) Analysis(com.smartystreets.api.us_street.Analysis) ArrayList(java.util.ArrayList) Metadata(com.smartystreets.api.us_street.Metadata) ValidatedAddress(gov.ca.cwds.rest.api.domain.ValidatedAddress) Test(org.junit.Test)

Example 2 with Metadata

use of com.smartystreets.api.us_street.Metadata in project API by ca-cwds.

the class SmartyStreetTest method successfulWithMultipleCandidates.

@Test
public void successfulWithMultipleCandidates() throws Exception {
    ArrayList<Candidate> multiCandidates = new ArrayList<Candidate>();
    Candidate mockcandidate1 = mock(Candidate.class);
    Analysis mockanalysis1 = mock(Analysis.class);
    Components mockancomponents1 = mock(Components.class);
    Metadata mockanmetadata1 = mock(Metadata.class);
    Mockito.when(mockcandidate1.getDeliveryLine1()).thenReturn("106 Big Valley Rd");
    Mockito.when(mockcandidate1.getComponents()).thenReturn(mockancomponents1);
    Mockito.when(mockancomponents1.getCityName()).thenReturn("Folsom");
    Mockito.when(mockancomponents1.getState()).thenReturn("CA");
    Mockito.when(mockancomponents1.getZipCode()).thenReturn("95630");
    Mockito.when(mockcandidate1.getMetadata()).thenReturn(mockanmetadata1);
    Mockito.when(mockanmetadata1.getLongitude()).thenReturn(-121.13233);
    Mockito.when(mockanmetadata1.getLatitude()).thenReturn(38.64028);
    Mockito.when(mockcandidate1.getAnalysis()).thenReturn(mockanalysis1);
    Mockito.when(mockanalysis1.getDpvMatchCode()).thenReturn("Y");
    multiCandidates.add(mockcandidate1);
    Candidate mockcandidate2 = mock(Candidate.class);
    Analysis mockanalysis2 = mock(Analysis.class);
    Components mockancomponents2 = mock(Components.class);
    Metadata mockanmetadata2 = mock(Metadata.class);
    Mockito.when(mockcandidate2.getDeliveryLine1()).thenReturn("106 Big Valley Ct");
    Mockito.when(mockcandidate2.getComponents()).thenReturn(mockancomponents2);
    Mockito.when(mockancomponents2.getCityName()).thenReturn("Folsom");
    Mockito.when(mockancomponents2.getState()).thenReturn("CA");
    Mockito.when(mockancomponents2.getZipCode()).thenReturn("95630");
    Mockito.when(mockcandidate2.getMetadata()).thenReturn(mockanmetadata2);
    Mockito.when(mockanmetadata2.getLongitude()).thenReturn(-121.13232);
    Mockito.when(mockanmetadata2.getLatitude()).thenReturn(38.68207);
    Mockito.when(mockcandidate2.getAnalysis()).thenReturn(mockanalysis2);
    Mockito.when(mockanalysis2.getDpvMatchCode()).thenReturn("S");
    multiCandidates.add(mockcandidate2);
    String a = "106 Big Valley";
    String b = "folsom";
    String c = "ca";
    Integer z = 0;
    Mockito.doReturn(multiCandidates).when(spySmartyStreet).getSmartyStreetsCandidates(a, b, c, z);
    ValidatedAddress[] actual = spySmartyStreet.usStreetSingleAddress(a, b, c, z);
    ValidatedAddress[] expected = new ValidatedAddress[2];
    expected[0] = new ValidatedAddress("106 Big Valley Rd", "Folsom", "CA", 95630, -121.13233, 38.64028, true);
    expected[1] = new ValidatedAddress("106 Big Valley Ct", "Folsom", "CA", 95630, -121.13232, 38.68207, true);
    assertThat(actual[0], is(equalTo(expected[0])));
    assertThat(actual[1], is(equalTo(expected[1])));
}
Also used : Candidate(com.smartystreets.api.us_street.Candidate) Components(com.smartystreets.api.us_street.Components) Analysis(com.smartystreets.api.us_street.Analysis) ArrayList(java.util.ArrayList) Metadata(com.smartystreets.api.us_street.Metadata) ValidatedAddress(gov.ca.cwds.rest.api.domain.ValidatedAddress) Test(org.junit.Test)

Aggregations

Analysis (com.smartystreets.api.us_street.Analysis)2 Candidate (com.smartystreets.api.us_street.Candidate)2 Components (com.smartystreets.api.us_street.Components)2 Metadata (com.smartystreets.api.us_street.Metadata)2 ValidatedAddress (gov.ca.cwds.rest.api.domain.ValidatedAddress)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2