Search in sources :

Example 11 with Address

use of com.google.api.services.people.v1.model.Address in project data-transfer-project by google.

the class GoogleContactsExportConversionTest method testConversionToVCardAddress.

@Test
public void testConversionToVCardAddress() {
    // Set up test: person with a primary address and a secondary address
    String primaryStreet = "221B Baker St";
    String primaryCity = "London";
    String primaryPostcode = "NW1";
    String primaryCountry = "United Kingdom";
    com.google.api.services.people.v1.model.Address primaryAddress = new com.google.api.services.people.v1.model.Address().setStreetAddress(primaryStreet).setCity(primaryCity).setPostalCode(primaryPostcode).setCountry(primaryCountry).setMetadata(PRIMARY_FIELD_METADATA);
    String altStreet = "42 Wallaby Way";
    String altCity = "Sydney";
    String altRegion = "New South Wales";
    String altCountry = "Australia";
    com.google.api.services.people.v1.model.Address altAddress = new com.google.api.services.people.v1.model.Address().setStreetAddress(altStreet).setCity(altCity).setRegion(altRegion).setCountry(altCountry).setMetadata(SECONDARY_FIELD_METADATA);
    Person person = DEFAULT_PERSON.setAddresses(Arrays.asList(altAddress, primaryAddress));
    // Run test
    VCard vCard = GoogleContactsExporter.convert(person);
    // Check results for correct values and preferences
    List<Address> actualPrimaryAddressList = getPropertiesWithPreference(vCard, Address.class, VCARD_PRIMARY_PREF);
    assertThat(actualPrimaryAddressList.stream().map(Address::getStreetAddress).collect(Collectors.toList())).containsExactly(primaryStreet);
    List<Address> actualAltAddressList = getPropertiesWithPreference(vCard, Address.class, VCARD_PRIMARY_PREF + 1);
    assertThat(actualAltAddressList.stream().map(Address::getRegion).collect(Collectors.toList())).containsExactly(altRegion);
}
Also used : EmailAddress(com.google.api.services.people.v1.model.EmailAddress) Address(ezvcard.property.Address) Person(com.google.api.services.people.v1.model.Person) VCard(ezvcard.VCard) Test(org.junit.Test)

Example 12 with Address

use of com.google.api.services.people.v1.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) 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) SOURCE_PARAM_NAME_TYPE(org.dataportabilityproject.datatransfer.google.common.GoogleStaticObjects.SOURCE_PARAM_NAME_TYPE) Pair(com.google.gdata.util.common.base.Pair) Person(com.google.api.services.people.v1.model.Person) List(java.util.List) CONTACT_SOURCE_TYPE(org.dataportabilityproject.datatransfer.google.common.GoogleStaticObjects.CONTACT_SOURCE_TYPE) Nullable(com.google.gdata.util.common.base.Nullable) Address(com.google.api.services.people.v1.model.Address) Email(ezvcard.property.Email) VCARD_PRIMARY_PREF(org.dataportabilityproject.datatransfer.google.common.GoogleStaticObjects.VCARD_PRIMARY_PREF) 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)

Example 13 with Address

use of com.google.api.services.people.v1.model.Address in project data-transfer-project by google.

the class GoogleContactToVCardConverterTest method testConversionToVCardAddress.

@Test
public void testConversionToVCardAddress() {
    // Set up test: person with a primary address and a secondary address
    String primaryStreet = "221B Baker St";
    String primaryCity = "London";
    String primaryPostcode = "NW1";
    String primaryCountry = "United Kingdom";
    com.google.api.services.people.v1.model.Address primaryAddress = new com.google.api.services.people.v1.model.Address().setStreetAddress(primaryStreet).setCity(primaryCity).setPostalCode(primaryPostcode).setCountry(primaryCountry).setMetadata(PRIMARY_FIELD_METADATA);
    String altStreet = "42 Wallaby Way";
    String altCity = "Sydney";
    String altRegion = "New South Wales";
    String altCountry = "Australia";
    com.google.api.services.people.v1.model.Address altAddress = new com.google.api.services.people.v1.model.Address().setStreetAddress(altStreet).setCity(altCity).setRegion(altRegion).setCountry(altCountry).setMetadata(SECONDARY_FIELD_METADATA);
    Person person = DEFAULT_PERSON.setAddresses(Arrays.asList(altAddress, primaryAddress));
    // Run test
    VCard vCard = GoogleContactToVCardConverter.convert(person);
    // Check results for correct values and preferences
    List<Address> actualPrimaryAddressList = getPropertiesWithPreference(vCard, Address.class, VCARD_PRIMARY_PREF);
    assertThat(actualPrimaryAddressList.stream().map(Address::getStreetAddress).collect(Collectors.toList())).containsExactly(primaryStreet);
    List<Address> actualAltAddressList = getPropertiesWithPreference(vCard, Address.class, VCARD_PRIMARY_PREF + 1);
    assertThat(actualAltAddressList.stream().map(Address::getRegion).collect(Collectors.toList())).containsExactly(altRegion);
}
Also used : EmailAddress(com.google.api.services.people.v1.model.EmailAddress) Address(ezvcard.property.Address) Person(com.google.api.services.people.v1.model.Person) VCard(ezvcard.VCard) Test(org.junit.Test)

Example 14 with Address

use of com.google.api.services.people.v1.model.Address in project gpconnect-demonstrator by nhsconnect.

the class OrganizationResourceProvider method getValidAddress.

private Address getValidAddress() {
    Address orgAddress = new Address();
    orgAddress.setType(AddressType.PHYSICAL);
    orgAddress.setUse(AddressUse.WORK);
    return orgAddress;
}
Also used : Address(org.hl7.fhir.dstu3.model.Address)

Example 15 with Address

use of com.google.api.services.people.v1.model.Address in project cloudbreak by hortonworks.

the class AwsResourceConnector method releaseReservedIp.

private void releaseReservedIp(AmazonEC2 client, Iterable<CloudResource> resources) {
    CloudResource elasticIpResource = getReservedIp(resources);
    if (elasticIpResource != null && elasticIpResource.getName() != null) {
        Address address;
        try {
            DescribeAddressesResult describeResult = client.describeAddresses(new DescribeAddressesRequest().withAllocationIds(elasticIpResource.getName()));
            address = describeResult.getAddresses().get(0);
        } catch (AmazonServiceException e) {
            if (e.getErrorMessage().equals("The allocation ID '" + elasticIpResource.getName() + "' does not exist")) {
                LOGGER.warn("Elastic IP with allocation ID '{}' not found. Ignoring IP release.", elasticIpResource.getName());
                return;
            } else {
                throw e;
            }
        }
        if (address.getAssociationId() != null) {
            client.disassociateAddress(new DisassociateAddressRequest().withAssociationId(elasticIpResource.getName()));
        }
        client.releaseAddress(new ReleaseAddressRequest().withAllocationId(elasticIpResource.getName()));
    }
}
Also used : Address(com.amazonaws.services.ec2.model.Address) DisassociateAddressRequest(com.amazonaws.services.ec2.model.DisassociateAddressRequest) DescribeAddressesResult(com.amazonaws.services.ec2.model.DescribeAddressesResult) DescribeAddressesRequest(com.amazonaws.services.ec2.model.DescribeAddressesRequest) AmazonServiceException(com.amazonaws.AmazonServiceException) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) ReleaseAddressRequest(com.amazonaws.services.ec2.model.ReleaseAddressRequest)

Aggregations

Address (com.amazonaws.services.ec2.model.Address)7 Person (com.google.api.services.people.v1.model.Person)7 DescribeAddressesResult (com.amazonaws.services.ec2.model.DescribeAddressesResult)5 VCard (ezvcard.VCard)5 Test (org.junit.Test)5 DescribeAddressesRequest (com.amazonaws.services.ec2.model.DescribeAddressesRequest)4 EmailAddress (com.google.api.services.people.v1.model.EmailAddress)4 Address (org.hl7.fhir.dstu3.model.Address)4 AmazonEC2 (com.amazonaws.services.ec2.AmazonEC2)3 Address (com.google.api.services.people.v1.model.Address)3 AssociateAddressRequest (com.amazonaws.services.ec2.model.AssociateAddressRequest)2 DisassociateAddressRequest (com.amazonaws.services.ec2.model.DisassociateAddressRequest)2 Name (com.google.api.services.people.v1.model.Name)2 PhoneNumber (com.google.api.services.people.v1.model.PhoneNumber)2 Truth.assertThat (com.google.common.truth.Truth.assertThat)2 Nullable (com.google.gdata.util.common.base.Nullable)2 Pair (com.google.gdata.util.common.base.Pair)2 InstanceInfo (com.netflix.appinfo.InstanceInfo)2 Contact (de.opendiabetes.vault.plugin.importer.googlecrawler.models.Contact)2 Address (ezvcard.property.Address)2