void testDescribe() {
for (String region : ec2Client.getConfiguredRegions()) {
Set<SecurityGroup> allResults = client.describeSecurityGroupsInRegion(region);
assertNotNull(allResults);
if (allResults.size() >= 1) {
final SecurityGroup group = getLast(allResults);
// in case there are multiple groups with the same name, which is the case with VPC
ImmutableSet<SecurityGroup> expected = FluentIterable.from(allResults)
.filter(new Predicate<SecurityGroup>() {
@Override
public boolean apply(SecurityGroup in) {
return group.getName().equals(in.getName());
}
}).toSet();
ImmutableSet<SecurityGroup> result = ImmutableSet.copyOf(client.describeSecurityGroupsInRegion(region,
group.getName()));
// the above command has a chance of returning less groups than the original
assertTrue(expected.containsAll(result));
}
}
}