@Test public void testConvertWithSecurityRulesAndEmptyGroupIds() { SecurityGroupRequest securityGroupRequest = new SecurityGroupRequest(); SecurityRuleRequest ruleRequest = new SecurityRuleRequest(); ruleRequest.setModifiable(false); ruleRequest.setPorts(List.of("22")); ruleRequest.setProtocol("tcp"); ruleRequest.setSubnet("0.0.0.0/0"); securityGroupRequest.setSecurityRules(List.of(ruleRequest)); securityGroupRequest.setSecurityGroupIds(Set.of()); SecurityRule securityRule = new SecurityRule(); securityRule.setCidr("0.0.0.0/0"); securityRule.setProtocol("tcp"); securityRule.setPorts("22"); securityRule.setModifiable(false); when(securityRuleConverter.convert(ruleRequest)).thenReturn(securityRule); SecurityGroup result = underTest.convert(securityGroupRequest); assertNotNull(result.getSecurityGroupIds()); assertTrue(result.getSecurityGroupIds().isEmpty()); assertNotNull(result.getSecurityRules()); assertEquals(1, result.getSecurityRules().size()); assertEquals(securityRule, result.getSecurityRules().iterator().next()); }
@Override public SecurityGroup convert(@Nonnull SecurityGroupRequest source) { SecurityGroup entity = new SecurityGroup(); entity.setName(missingResourceNameGenerator.generateName(APIResourceType.SECURITY_GROUP)); entity.setSecurityGroupIds(convertSecurityGroupIdsToList(source)); entity.setSecurityRules(convertSecurityRules(source.getSecurityRules(), entity)); return entity; }
SecurityGroupRequestToSecurityGroupConverter implements Converter<SecurityGroupRequest, SecurityGroup> { @Override public SecurityGroup convert(@Nonnull SecurityGroupRequest source) { SecurityGroup entity = new SecurityGroup(); entity.setName(missingResourceNameGenerator.generateName(APIResourceType.SECURITY_GROUP)); entity.setSecurityGroupIds(convertSecurityGroupIdsToList(source)); entity.setSecurityRules(convertSecurityRules(source.getSecurityRules(), entity)); return entity; } }
SecurityGroupRequestToSecurityGroupConverter implements Converter<SecurityGroupRequest, SecurityGroup> { @Override public SecurityGroup convert(@Nonnull SecurityGroupRequest source) { SecurityGroup entity = new SecurityGroup(); entity.setName(missingResourceNameGenerator.generateName(APIResourceType.SECURITY_GROUP)); entity.setSecurityGroupIds(convertSecurityGroupIdsToList(source)); entity.setSecurityRules(convertSecurityRules(source.getSecurityRules(), entity)); return entity; }  }
SecurityGroupRequestToSecurityGroupConverter implements Converter<SecurityGroupRequest, SecurityGroup> { @Override public SecurityGroup convert(@Nonnull SecurityGroupRequest source) { SecurityGroup entity = new SecurityGroup(); entity.setName(missingResourceNameGenerator.generateName(APIResourceType.SECURITY_GROUP)); entity.setSecurityGroupIds(convertSecurityGroupIdsToList(source)); entity.setSecurityRules(convertSecurityRules(source.getSecurityRules(), entity)); return entity; }  @Override SecurityGroup convert(@Nonnull SecurityGroupRequest source); }
SecurityGroupRequestToSecurityGroupConverter implements Converter<SecurityGroupRequest, SecurityGroup> { @Override public SecurityGroup convert(@Nonnull SecurityGroupRequest source) { SecurityGroup entity = new SecurityGroup(); entity.setName(missingResourceNameGenerator.generateName(APIResourceType.SECURITY_GROUP)); entity.setSecurityGroupIds(convertSecurityGroupIdsToList(source)); entity.setSecurityRules(convertSecurityRules(source.getSecurityRules(), entity)); return entity; }  @Override SecurityGroup convert(@Nonnull SecurityGroupRequest source);  }