use of org.hl7.fhir.dstu3.model.Address in project GNS by MobilityFirst.
the class AWSEC2 method describeElasticIPs.
/**
*
* @param ec2
*/
public static void describeElasticIPs(AmazonEC2 ec2) {
StringBuilder output = new StringBuilder();
String prefix = currentTab + "Elastic IPs: ";
DescribeAddressesResult describeAddressesResult = ec2.describeAddresses();
for (Address address : describeAddressesResult.getAddresses()) {
output.append(prefix);
prefix = ", ";
output.append(address.getPublicIp());
}
System.out.println(output);
}
use of org.hl7.fhir.dstu3.model.Address in project gpconnect-demonstrator by nhsconnect.
the class LocationResourceProvider method createAddress.
private Address createAddress(LocationDetails locationDetails) {
Address address = new Address();
List<StringType> list = new LinkedList<>();
list.add(new StringType(locationDetails.getAddressLine()));
list.add(new StringType(locationDetails.getAddressCity()));
address.setLine(list);
address.setCity(locationDetails.getAddressDistrict());
address.setDistrict(locationDetails.getAddressState());
address.setPostalCode(locationDetails.getAddressPostalCode());
address.setCountry(locationDetails.getAddressCountry());
return address;
}
use of org.hl7.fhir.dstu3.model.Address in project BachelorPraktikum by lucasbuschlinger.
the class GooglePlaces method fetchOwnAddresses.
// /**
// * Setter for the query keyword search params.
// * @param keywordSearchParams valid search params that will be appended to the query
// */
// public void setKeywordSearchParams(final String[] keywordSearchParams) {
// for (String param : keywordSearchParams) {
// keywordSearch = keywordSearch + " OR (" + param.toLowerCase() + ")";
// }
// }
//
// /**
// * Searches the context with the previously set keyword search params
// * and the given location (latitude, longitude) and radius (accuracy).
// * @param latitude a valid latitude
// * @param longitude a valid longitude
// * @param accuracy a radius in meters
// * @return The name of the result if there was a place found with the given query params, otherwise "AWAY"
// */
// public String keywordSearch(final double latitude, final double longitude, final int accuracy) {
// try {
// PlacesSearchResult[] results = PlacesApi
// .nearbySearchQuery(context, new LatLng(latitude, longitude))
// .radius(accuracy)
// .keyword(keywordSearch)
// .await().results;
// if (results.length == 1) {
// return results[0].name;
// } else {
// for (PlacesSearchResult sr : results) {
// boolean isPolitical = false;
// for (String st : sr.types) {
// if (st.equals("political")) {
// isPolitical = true;
// }
// }
//
// if (!isPolitical) {
// return sr.name;
// }
// }
// }
// } catch (ApiException | InterruptedException | IOException e) {
// e.printStackTrace();
// }
//
// return "AWAY";
// }
/**
* Retrieves the own addresses of the current user.
*/
public void fetchOwnAddresses() {
if (context != null) {
Person me = GooglePeople.getInstance().getProfile();
if (me.getAddresses() != null) {
for (Address res : me.getAddresses()) {
String name = res.getFormattedType();
List<Address> address = Arrays.asList(res);
ownAddresses.add(new Contact(name, address));
}
}
}
}
use of org.hl7.fhir.dstu3.model.Address in project data-transfer-project by google.
the class VCardToGoogleContactConverterTest 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 = VCardToGoogleContactConverter.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);
}
use of org.hl7.fhir.dstu3.model.Address in project photon-model by vmware.
the class AWSSubnetTaskServiceTest method testCreateSubnetWithOutboundAccess.
@Test
public void testCreateSubnetWithOutboundAccess() throws Throwable {
// provision a "public" subnet first
SubnetState publicSubnetState = provisionSubnet(AWS_NON_EXISTING_PUBLIC_SUBNET_NAME, AWS_NON_EXISTING_PUBLIC_SUBNET_CIDR, null);
assertNotNull(publicSubnetState.id);
assertEquals(LifecycleState.READY, publicSubnetState.lifecycleState);
SubnetState subnetState = provisionSubnet(AWS_NON_EXISTING_SUBNET_NAME, AWS_NON_EXISTING_SUBNET_CIDR, publicSubnetState.documentSelfLink);
assertNotNull(subnetState.id);
assertEquals(LifecycleState.READY, subnetState.lifecycleState);
if (!this.isMock) {
// Verify that the subnet was created.
DescribeSubnetsRequest describeRequest = new DescribeSubnetsRequest().withSubnetIds(Collections.singletonList(subnetState.id));
List<Subnet> subnets = this.client.describeSubnets(describeRequest).getSubnets();
assertNotNull(subnets);
assertEquals(1, subnets.size());
// Verify that a NAT gateway was created
assertNotNull(subnetState.customProperties);
String natGatewayId = subnetState.customProperties.get(AWS_NAT_GATEWAY_ID);
String routeTableId = subnetState.customProperties.get(AWS_ROUTE_TABLE_ID);
String allocationId = subnetState.customProperties.get(AWS_ELASTIC_IP_ALLOCATION_ID);
assertNotNull(natGatewayId);
assertNotNull(routeTableId);
assertNotNull(allocationId);
DescribeNatGatewaysRequest describeNatGatewaysRequest = new DescribeNatGatewaysRequest().withNatGatewayIds(Collections.singletonList(natGatewayId));
List<NatGateway> natGateways = this.client.describeNatGateways(describeNatGatewaysRequest).getNatGateways();
assertNotNull(natGateways);
assertEquals(1, natGateways.size());
NatGateway natGateway = natGateways.get(0);
assertEquals(publicSubnetState.id, natGateway.getSubnetId());
assertNotNull(natGateway.getNatGatewayAddresses());
assertEquals(1, natGateway.getNatGatewayAddresses().size());
assertEquals(allocationId, natGateway.getNatGatewayAddresses().get(0).getAllocationId());
assertEquals("available", natGateways.get(0).getState());
// verify that a route table was created
DescribeRouteTablesRequest describeRouteTablesRequest = new DescribeRouteTablesRequest().withRouteTableIds(Collections.singletonList(routeTableId));
List<RouteTable> routeTables = this.client.describeRouteTables(describeRouteTablesRequest).getRouteTables();
assertNotNull(routeTables);
assertEquals(1, routeTables.size());
RouteTable routeTable = routeTables.get(0);
assertNotNull(routeTable.getAssociations());
assertEquals(1, routeTable.getAssociations().size());
assertEquals(subnetState.id, routeTable.getAssociations().get(0).getSubnetId());
assertNotNull(routeTable.getRoutes());
assertEquals(2, routeTable.getRoutes().size());
boolean hasRouteToNatGateway = false;
for (Route route : routeTable.getRoutes()) {
if (route.getDestinationCidrBlock().equals("0.0.0.0/0") && route.getNatGatewayId() != null && route.getNatGatewayId().equals(natGatewayId)) {
hasRouteToNatGateway = true;
break;
}
}
assertTrue(hasRouteToNatGateway);
// Verify that an IP address allocation was created
DescribeAddressesRequest describeAddressesRequest = new DescribeAddressesRequest().withAllocationIds(Collections.singletonList(allocationId));
List<Address> addresses = this.client.describeAddresses(describeAddressesRequest).getAddresses();
assertNotNull(addresses);
assertEquals(1, addresses.size());
}
// delete the subnet
kickOffSubnetProvision(InstanceRequestType.DELETE, subnetState, TaskStage.FINISHED);
if (!this.isMock) {
// Verify that the subnet was deleted.
DescribeSubnetsRequest describeRequest = new DescribeSubnetsRequest().withSubnetIds(Collections.singletonList(subnetState.id));
try {
this.client.describeSubnets(describeRequest).getSubnets();
fail("Subnet should not exist in AWS.");
} catch (AmazonEC2Exception ex) {
assertEquals(HttpResponseStatus.BAD_REQUEST.code(), ex.getStatusCode());
}
// Verify that the NAT gateway was deleted
String natGatewayId = subnetState.customProperties.get(AWS_NAT_GATEWAY_ID);
String routeTableId = subnetState.customProperties.get(AWS_ROUTE_TABLE_ID);
String allocationId = subnetState.customProperties.get(AWS_ELASTIC_IP_ALLOCATION_ID);
DescribeNatGatewaysRequest describeNatGatewaysRequest = new DescribeNatGatewaysRequest().withNatGatewayIds(Collections.singletonList(natGatewayId));
List<NatGateway> natGateways = this.client.describeNatGateways(describeNatGatewaysRequest).getNatGateways();
assertNotNull(natGateways);
assertEquals(1, natGateways.size());
assertEquals("deleted", natGateways.get(0).getState());
// Verify that the route table was deleted
DescribeRouteTablesRequest describeRouteTablesRequest = new DescribeRouteTablesRequest().withRouteTableIds(Collections.singletonList(routeTableId));
try {
this.client.describeRouteTables(describeRouteTablesRequest).getRouteTables();
fail("Route table should not exist in AWS.");
} catch (AmazonEC2Exception ex) {
assertEquals(HttpResponseStatus.BAD_REQUEST.code(), ex.getStatusCode());
}
DescribeAddressesRequest describeAddressesRequest = new DescribeAddressesRequest().withAllocationIds(Collections.singletonList(allocationId));
try {
this.client.describeAddresses(describeAddressesRequest).getAddresses();
fail("IP address allocation should not exist in AWS.");
} catch (AmazonEC2Exception ex) {
assertEquals(HttpResponseStatus.BAD_REQUEST.code(), ex.getStatusCode());
}
}
}
Aggregations