/** * Test helper - makes a DBInstance having the specified security group names. */ private DBInstance makeDBInstanceWithSecurityGroups(String... securityGroupIds) { DBInstance dbInstance = new DBInstance(); dbInstance.setDBInstanceIdentifier(INSTANCE_NAME); if (ArrayUtils.isNotEmpty(securityGroupIds)) { List<VpcSecurityGroupMembership> securityGroups = new ArrayList<VpcSecurityGroupMembership>(); for (String securityGroupId : securityGroupIds) { securityGroups.add(makeVpcSecurityGroupMembership(securityGroupId)); } dbInstance.setVpcSecurityGroups(securityGroups); } return dbInstance; }
/** * Extracts the VPC security group ids from the instance. */ public Collection<String> extractVpcSecurityGroupIds(DBInstance dbInstance) { if (dbInstance != null && CollectionUtils.isNotEmpty(dbInstance.getVpcSecurityGroups())) { List<String> ids = new ArrayList<String>(); for (VpcSecurityGroupMembership group : dbInstance.getVpcSecurityGroups()) { ids.add(group.getVpcSecurityGroupId()); } return ids; } return null; }
private VpcSecurityGroupMembership makeVpcSecurityGroupMembership(String securityGroupId) { VpcSecurityGroupMembership securityGroup = new VpcSecurityGroupMembership(); securityGroup.setVpcSecurityGroupId(securityGroupId); return securityGroup; }