@Test(dependsOnMethods = "testCreateSubnetInRegion") public void testList() { FluentIterable<Subnet> subnets = subnetClient.describeSubnetsInRegionWithFilter(region, ImmutableMultimap.<String, String>of()); Optional<Subnet> subnetFound = Iterables.tryFind(subnets, new Predicate<Subnet>() { @Override public boolean apply(Subnet input) { return input != null && input.getSubnetId().equals(subnet.getSubnetId()); } }); assertTrue(subnetFound.isPresent(), "subnets=" + ImmutableList.copyOf(subnets)); }
@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()); }
public void describeSubnetInRegionWithFilterWhen404() throws Exception { enqueueRegions(DEFAULT_REGION); enqueue(DEFAULT_REGION, new MockResponse().setResponseCode(404)); FluentIterable<Subnet> results = subnetApi().describeSubnetsInRegionWithFilter(DEFAULT_REGION, ImmutableMultimap.of("vpc-id", "vpc-1a2b3c4d")); assertTrue(Iterables.isEmpty(results)); assertPosted(DEFAULT_REGION, "Action=DescribeRegions"); assertPosted(DEFAULT_REGION, "Action=DescribeSubnets&Filter.1.Name=vpc-id&Filter.1.Value.1=vpc-1a2b3c4d"); }
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"); }