@Override public boolean apply(Subnet input) { return input != null && input.getSubnetId().equals(subnet.getSubnetId()); } });
@Test(dependsOnMethods = "testCreateSubnetInRegion") public void testGet() { FluentIterable<Subnet> subnets = subnetClient.describeSubnetsInRegion(region, subnet.getSubnetId()); Subnet subnetFound = Iterables.getOnlyElement(subnets); assertEquals(subnetFound.getSubnetId(), subnet.getSubnetId()); }
@Test(dependsOnMethods = "testCreateSubnetInRegion") public void testFilter() { FluentIterable<Subnet> subnets = subnetClient.describeSubnetsInRegionWithFilter(region, ImmutableMultimap.of("subnet-id", subnet.getSubnetId())); Subnet subnetFound = Iterables.getOnlyElement(subnets); assertEquals(subnetFound.getSubnetId(), subnet.getSubnetId()); }
@Test(dependsOnMethods = {"testGet", "testFilter", "testList"}, alwaysRun = true) public void testDelete() { if (subnet != null) { String subnetId = subnet.getSubnetId(); subnet = null; subnetClient.deleteSubnetInRegion(region, subnetId); } } }
private void checkSubnet(Subnet subnet) { getAnonymousLogger().info(format("subnet %s vpc: %s", subnet.getSubnetId(), subnet.getVpcId())); checkNotNull(subnet.getSubnetId(), "Id: Subnet %s", subnet); checkNotNull(subnet.getVpcId(), "VPC: Subnet %s", subnet); checkNotNull(subnet.getSubnetState(), "SubnetState: Subnet %s", subnet); checkNotNull(subnet.getCidrBlock(), "CIDR Block: %s", subnet); checkNotNull(subnet.getAvailabilityZone(), "Availability Zone: %s", subnet); }
private void checkSubnet(Subnet subnet) { getAnonymousLogger().info(format("subnet %s vpc: %s", subnet.getSubnetId(), subnet.getVpcId())); checkNotNull(subnet.getSubnetId(), "Id: Subnet %s", subnet); checkNotNull(subnet.getVpcId(), "VPC: Subnet %s", subnet); checkNotNull(subnet.getSubnetState(), "SubnetState: Subnet %s", subnet); checkNotNull(subnet.getCidrBlock(), "CIDR Block: %s", subnet); checkNotNull(subnet.getAvailabilityZone(), "Availability Zone: %s", subnet); }
@Test(dependsOnMethods = "testCreateSubnetInRegion") public void testModifySubnetAttribute() { final boolean result = subnetClient.modifySubnetAttribute(region, subnet.getSubnetId(), mapPublicIpOnLaunch(true)); assertTrue(result, "Failed to modify subnet attribute"); }
@Test(dependsOnMethods = "testAssociateWithOptions") public void testAssociate() { associationId = routeTableApi.associateRouteTable(TEST_REGION, routeTable.id(), subnet.getSubnetId()); assertNotNull(associationId, "Failed to obtain association id for " + routeTable.id() + " and " + subnet.getSubnetId()); routeTable = routeTableApi.describeRouteTables(TEST_REGION, routeTable.id()).toList().get(0); assertEquals(routeTable.associationSet().size(), 1, "Could not find expected association in routeTable " + routeTable.id()); }
@Test(dependsOnMethods = "testDisassociateWithOptions") public void testDisassociate() { final boolean result = routeTableApi.disassociateRouteTable(TEST_REGION, associationId); assertTrue(result, "Failed to disassociate " + associationId + " from " + routeTable.id()); routeTable = routeTableApi.describeRouteTables(TEST_REGION, routeTable.id()).toList().get(0); assertEquals(routeTable.associationSet().size(), 0, "Found associations where none should exist in " + routeTable.id() + ": " + routeTable.associationSet()); subnetApi.deleteSubnetInRegion(TEST_REGION, subnet.getSubnetId()); }
@Test public void testListSubnets() { ImmutableSet<Subnet> subnets = api().list().toSet(); getAnonymousLogger().info("subnets: " + subnets.size()); for (Subnet subnet : subnets) { checkSubnet(subnet); assertEquals(api().filter(new SubnetFilterBuilder().subnetId(subnet.getSubnetId()).build()).get(0), subnet); } }
@Test public void testListSubnets() { ImmutableSet<Subnet> subnets = api().list().toSet(); getAnonymousLogger().info("subnets: " + subnets.size()); for (Subnet subnet : subnets) { checkSubnet(subnet); assertEquals(api().filter(new SubnetFilterBuilder().subnetId(subnet.getSubnetId()).build()).get(0), subnet); } }
@Test(dependsOnMethods = "testCreate") public void testAssociateWithOptions() { subnet = subnetApi.createSubnetInRegion(TEST_REGION, vpc.id(), VPC_SUBNET); assertNotNull(subnet, "Failed to create subnet in " + vpc.id()); try { routeTableApi.associateRouteTable(TEST_REGION, routeTable.id(), subnet.getSubnetId(), dryRun()); Assert.fail("Expected 'DryRunOperation' exception was not thrown"); } catch (AWSResponseException e) { assertDryRun(e); } }
@Override @AfterClass(groups = { "integration", "live" }) public void tearDownContext() { try { try { if (subnet != null) { subnetClient.deleteSubnetInRegion(region, subnet.getSubnetId()); } } finally { if (vpc != null) { vpcClient.deleteVpc(region, vpc.id()); } } } finally { super.tearDownContext(); } }
public void describeSubnetInRegionWithFilter() throws Exception { enqueueRegions(DEFAULT_REGION); enqueue(DEFAULT_REGION, new MockResponse().setBody(describeSubnetsResponse)); FluentIterable<Subnet> results = subnetApi().describeSubnetsInRegionWithFilter(DEFAULT_REGION, ImmutableMultimap.of("vpc-id", "vpc-1a2b3c4d", "availabilityZone", "us-east-1a")); Subnet result = Iterables.getOnlyElement(results); assertEquals(result.getSubnetId(), "subnet-9d4a7b6c"); assertEquals(result.getSubnetState().value(), "available"); assertEquals(result.getVpcId(), "vpc-1a2b3c4d"); assertEquals(result.getCidrBlock(), "10.0.1.0/24"); assertEquals(result.getAvailabilityZone(), "us-east-1a"); assertEquals(result.getAvailableIpAddressCount(), 251); assertPosted(DEFAULT_REGION, "Action=DescribeRegions"); assertPosted(DEFAULT_REGION, "Action=DescribeSubnets&Filter.1.Name=vpc-id&Filter.1.Value.1=vpc-1a2b3c4d&Filter.2.Name=availabilityZone&Filter.2.Value.1=us-east-1a"); }
public void describeSubnetInRegion() throws Exception { enqueueRegions(DEFAULT_REGION); enqueue(DEFAULT_REGION, new MockResponse().setBody(describeSubnetsResponse)); FluentIterable<Subnet> results = subnetApi().describeSubnetsInRegion(DEFAULT_REGION); Subnet result = Iterables.getOnlyElement(results); assertEquals(result.getSubnetId(), "subnet-9d4a7b6c"); assertEquals(result.getSubnetState().value(), "available"); assertEquals(result.getVpcId(), "vpc-1a2b3c4d"); assertEquals(result.getCidrBlock(), "10.0.1.0/24"); assertEquals(result.getAvailabilityZone(), "us-east-1a"); assertEquals(result.getAvailableIpAddressCount(), 251); assertPosted(DEFAULT_REGION, "Action=DescribeRegions"); assertPosted(DEFAULT_REGION, "Action=DescribeSubnets"); }
public Builder from(Subnet in) { return this.subnetId(in.getSubnetId()).subnetState(in.getSubnetState()).vpcId(in.getVpcId()) .cidrBlock(in.getCidrBlock()).availableIpAddressCount(in.getAvailableIpAddressCount()) .availabilityZone(in.getAvailabilityZone()).tags(in.getTags()); } }
public Builder from(Subnet in) { return this.subnetId(in.getSubnetId()).subnetState(in.getSubnetState()).vpcId(in.getVpcId()) .cidrBlock(in.getCidrBlock()).availableIpAddressCount(in.getAvailableIpAddressCount()) .availabilityZone(in.getAvailabilityZone()).tags(in.getTags()); } }
public Builder from(Subnet in) { return this.subnetId(in.getSubnetId()).subnetState(in.getSubnetState()).vpcId(in.getVpcId()) .cidrBlock(in.getCidrBlock()).availableIpAddressCount(in.getAvailableIpAddressCount()) .availabilityZone(in.getAvailabilityZone()).tags(in.getTags()); } }
public Builder from(Subnet in) { return this.subnetId(in.getSubnetId()).subnetState(in.getSubnetState()).vpcId(in.getVpcId()) .cidrBlock(in.getCidrBlock()).availableIpAddressCount(in.getAvailableIpAddressCount()) .availabilityZone(in.getAvailabilityZone()).tags(in.getTags()); } }
public Builder from(Subnet in) { return this.subnetId(in.getSubnetId()).subnetState(in.getSubnetState()).vpcId(in.getVpcId()) .cidrBlock(in.getCidrBlock()).availableIpAddressCount(in.getAvailableIpAddressCount()) .availabilityZone(in.getAvailabilityZone()).tags(in.getTags()); } }