Search in sources :

Example 36 with Address

use of com.amazonaws.services.ec2.model.Address in project data-transfer-project by google.

the class GoogleContactsImportConversionTest method testConversionToGoogleAddresses.

@Test
public void testConversionToGoogleAddresses() {
    // Set up vCard with a primary address and a secondary address
    String primaryStreet = "221B Baker St";
    String primaryLocality = "London";
    ezvcard.property.Address primaryAddress = new ezvcard.property.Address();
    primaryAddress.setStreetAddress(primaryStreet);
    primaryAddress.setLocality(primaryLocality);
    primaryAddress.setPref(VCARD_PRIMARY_PREF);
    String altStreet = "42 Wallaby Way";
    String altLocality = "Sydney";
    ezvcard.property.Address altAddress = new ezvcard.property.Address();
    altAddress.setStreetAddress(altStreet);
    altAddress.setLocality(altLocality);
    altAddress.setPref(VCARD_PRIMARY_PREF + 1);
    // Add addresses to vCard.  Order shouldn't matter.
    VCard vCard = defaultVCard;
    vCard.addAddress(primaryAddress);
    vCard.addAddress(altAddress);
    // Run test
    Person person = GoogleContactsImporter.convert(vCard);
    // Check results
    // Check correct number of addresses
    assertThat(person.getAddresses().size()).isEqualTo(2);
    // Check primary address
    List<Address> actualPrimaryAddresses = person.getAddresses().stream().filter(a -> a.getMetadata().getPrimary()).collect(Collectors.toList());
    List<String> actualPrimaryAddressStreets = getValuesFromFields(actualPrimaryAddresses, Address::getStreetAddress);
    assertThat(actualPrimaryAddressStreets).containsExactly(primaryStreet);
    // Check secondary address
    List<Address> actualSecondaryAddresses = person.getAddresses().stream().filter(a -> !a.getMetadata().getPrimary()).collect(Collectors.toList());
    List<String> actualSecondaryAddressStreets = getValuesFromFields(actualSecondaryAddresses, Address::getStreetAddress);
    assertThat(actualSecondaryAddressStreets).containsExactly(altStreet);
}
Also used : VCard(ezvcard.VCard) SOURCE_PARAM_NAME_TYPE(org.datatransferproject.datatransfer.google.common.GoogleStaticObjects.SOURCE_PARAM_NAME_TYPE) VCARD_PRIMARY_PREF(org.datatransferproject.datatransfer.google.common.GoogleStaticObjects.VCARD_PRIMARY_PREF) EmailAddress(com.google.api.services.people.v1.model.EmailAddress) Telephone(ezvcard.property.Telephone) Test(org.junit.Test) PhoneNumber(com.google.api.services.people.v1.model.PhoneNumber) Truth.assertThat(com.google.common.truth.Truth.assertThat) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) StructuredName(ezvcard.property.StructuredName) CONTACT_SOURCE_TYPE(org.datatransferproject.datatransfer.google.common.GoogleStaticObjects.CONTACT_SOURCE_TYPE) Pair(com.google.gdata.util.common.base.Pair) Person(com.google.api.services.people.v1.model.Person) List(java.util.List) Nullable(com.google.gdata.util.common.base.Nullable) Address(com.google.api.services.people.v1.model.Address) Email(ezvcard.property.Email) Name(com.google.api.services.people.v1.model.Name) Collections(java.util.Collections) Before(org.junit.Before) EmailAddress(com.google.api.services.people.v1.model.EmailAddress) Address(com.google.api.services.people.v1.model.Address) VCard(ezvcard.VCard) Person(com.google.api.services.people.v1.model.Person) Test(org.junit.Test)

Aggregations

AmazonEC2 (com.amazonaws.services.ec2.AmazonEC2)8 Address (com.amazonaws.services.ec2.model.Address)7 Instance (com.amazonaws.services.ec2.model.Instance)7 Reservation (com.amazonaws.services.ec2.model.Reservation)7 DescribeAddressesResult (com.amazonaws.services.ec2.model.DescribeAddressesResult)6 Filter (com.amazonaws.services.ec2.model.Filter)6 List (java.util.List)6 Test (org.junit.Test)6 DescribeAddressesRequest (com.amazonaws.services.ec2.model.DescribeAddressesRequest)5 DescribeInstancesRequest (com.amazonaws.services.ec2.model.DescribeInstancesRequest)5 ArrayList (java.util.ArrayList)5 ReleaseAddressRequest (com.amazonaws.services.ec2.model.ReleaseAddressRequest)4 Address (com.google.api.services.people.v1.model.Address)4 Person (com.google.api.services.people.v1.model.Person)4 Address (org.hl7.fhir.dstu3.model.Address)4 AssociateAddressRequest (com.amazonaws.services.ec2.model.AssociateAddressRequest)3 DescribeInstancesResult (com.amazonaws.services.ec2.model.DescribeInstancesResult)3 Tag (com.amazonaws.services.ec2.model.Tag)3 Function (com.google.common.base.Function)3 TransportAddress (org.elasticsearch.common.transport.TransportAddress)3