@Test public void testApply() { IpPermissions authorization = IpPermissions.permitAnyProtocol(); org.jclouds.ec2.domain.SecurityGroup origGroup = org.jclouds.ec2.domain.SecurityGroup.builder() .region("us-east-1") .id("some-id") .name("some-group") .ownerId("some-owner") .description("some-description") .ipPermission(authorization) .build(); AWSEC2SecurityGroupToSecurityGroup parser = createGroupParser(ImmutableSet.of(provider)); SecurityGroup group = parser.apply(origGroup); assertEquals(group.getLocation(), provider); assertEquals(group.getId(), provider.getId() + "/" + origGroup.getId()); assertEquals(group.getProviderId(), origGroup.getId()); assertEquals(group.getName(), origGroup.getName()); assertEquals(group.getIpPermissions(), (Set<IpPermission>) origGroup); assertEquals(group.getOwnerId(), origGroup.getOwnerId()); }
@Test public void testApplyWithGroup() { NovaSecurityGroupInZoneToSecurityGroup parser = createGroupParser(); SecurityGroupInZone origGroup = new SecurityGroupInZone(securityGroupWithGroup(), zone.getId()); SecurityGroup newGroup = parser.apply(origGroup); assertEquals( newGroup.getId(), origGroup.getZone() + "/" + origGroup.getSecurityGroup().getId()); assertEquals(newGroup.getProviderId(), origGroup.getSecurityGroup().getId()); assertEquals(newGroup.getName(), origGroup.getSecurityGroup().getName()); assertEquals(newGroup.getOwnerId(), origGroup.getSecurityGroup().getTenantId()); assertEquals( newGroup.getIpPermissions(), ImmutableSet.copyOf( transform( origGroup.getSecurityGroup().getRules(), NovaSecurityGroupToSecurityGroupTest.ruleConverter))); assertEquals(newGroup.getLocation().getId(), origGroup.getZone()); }