@Test void testSetProviderSpecificNetworkShouldPopulateTheExistingNetworkWithTheNewNetworkData() { BaseNetwork awsNetwork = new AwsNetwork(); Set<CreatedSubnet> createdSubnets = createCreatedSubnets(); CreatedCloudNetwork createdCloudNetwork = new CreatedCloudNetwork("network-1", VPC_ID, createdSubnets); AwsNetwork actual = (AwsNetwork) underTest.setCreatedCloudNetwork(awsNetwork, createdCloudNetwork); assertEquals(createdCloudNetwork.getStackName(), actual.getName()); assertEquals(VPC_ID, actual.getVpcId()); assertTrue(SUBNET_IDS.containsAll(actual.getSubnetMetas().keySet())); assertEquals(SUBNET_1, awsNetwork.getSubnetMetas().get(SUBNET_1).getId()); assertEquals(SUBNET_1, awsNetwork.getSubnetMetas().get(SUBNET_1).getName()); assertEquals(AZ_1, awsNetwork.getSubnetMetas().get(SUBNET_1).getAvailabilityZone()); assertEquals(SUBNET_CIDR_1, awsNetwork.getSubnetMetas().get(SUBNET_1).getCidr()); assertFalse(awsNetwork.getSubnetMetas().get(SUBNET_1).isPrivateSubnet()); assertEquals(SUBNET_2, awsNetwork.getSubnetMetas().get(SUBNET_2).getId()); assertEquals(SUBNET_2, awsNetwork.getSubnetMetas().get(SUBNET_2).getName()); assertEquals(AZ_2, awsNetwork.getSubnetMetas().get(SUBNET_2).getAvailabilityZone()); assertEquals(SUBNET_CIDR_2, awsNetwork.getSubnetMetas().get(SUBNET_2).getCidr()); assertFalse(awsNetwork.getSubnetMetas().get(SUBNET_2).isPrivateSubnet()); assertEquals(SUBNET_3, awsNetwork.getSubnetMetas().get(SUBNET_3).getId()); assertEquals(SUBNET_3, awsNetwork.getSubnetMetas().get(SUBNET_3).getName()); assertEquals(AZ_3, awsNetwork.getSubnetMetas().get(SUBNET_3).getAvailabilityZone()); assertEquals(SUBNET_CIDR_3, awsNetwork.getSubnetMetas().get(SUBNET_3).getCidr()); assertFalse(awsNetwork.getSubnetMetas().get(SUBNET_3).isPrivateSubnet()); }
@Override public BaseNetwork setCreatedCloudNetwork(BaseNetwork baseNetwork, CreatedCloudNetwork createdCloudNetwork) { AwsNetwork awsNetwork = (AwsNetwork) baseNetwork; awsNetwork.setName(createdCloudNetwork.getStackName()); awsNetwork.setVpcId(createdCloudNetwork.getNetworkId()); awsNetwork.setSubnetMetas(createdCloudNetwork.getSubnets().stream() .collect(Collectors.toMap( CreatedSubnet::getSubnetId, subnet -> new CloudSubnet( subnet.getSubnetId(), subnet.getSubnetId(), subnet.getAvailabilityZone(), subnet.getCidr(), !subnet.isPublicSubnet(), subnet.isMapPublicIpOnLaunch(), subnet.isIgwAvailable(), subnet.getType()) ) ) ); return awsNetwork; }
AwsEnvironmentNetworkConverter extends EnvironmentBaseNetworkConverter { @Override public BaseNetwork setCreatedCloudNetwork(BaseNetwork baseNetwork, CreatedCloudNetwork createdCloudNetwork) { AwsNetwork awsNetwork = (AwsNetwork) baseNetwork; awsNetwork.setName(createdCloudNetwork.getStackName()); awsNetwork.setVpcId(createdCloudNetwork.getNetworkId()); awsNetwork.setSubnetMetas(createdCloudNetwork.getSubnets().stream() .collect(Collectors.toMap( CreatedSubnet::getSubnetId, subnet -> new CloudSubnet( subnet.getSubnetId(), subnet.getSubnetId(), subnet.getAvailabilityZone(), subnet.getCidr(), !subnet.isPublicSubnet(), subnet.isMapPublicIpOnLaunch(), subnet.isIgwAvailable(), subnet.getType()) ) ) ); return awsNetwork; } }
AwsEnvironmentNetworkConverter extends EnvironmentBaseNetworkConverter { @Override public BaseNetwork setCreatedCloudNetwork(BaseNetwork baseNetwork, CreatedCloudNetwork createdCloudNetwork) { AwsNetwork awsNetwork = (AwsNetwork) baseNetwork; awsNetwork.setName(createdCloudNetwork.getStackName()); awsNetwork.setVpcId(createdCloudNetwork.getNetworkId()); awsNetwork.setSubnetMetas(createdCloudNetwork.getSubnets().stream() .collect(Collectors.toMap( CreatedSubnet::getSubnetId, subnet -> new CloudSubnet( subnet.getSubnetId(), subnet.getSubnetId(), subnet.getAvailabilityZone(), subnet.getCidr(), !subnet.isPublicSubnet(), subnet.isMapPublicIpOnLaunch(), subnet.isIgwAvailable(), subnet.getType()) ) ) ); return awsNetwork; } AwsEnvironmentNetworkConverter(EnvironmentViewConverter environmentViewConverter); }
AwsEnvironmentNetworkConverter extends EnvironmentBaseNetworkConverter { @Override public BaseNetwork setCreatedCloudNetwork(BaseNetwork baseNetwork, CreatedCloudNetwork createdCloudNetwork) { AwsNetwork awsNetwork = (AwsNetwork) baseNetwork; awsNetwork.setName(createdCloudNetwork.getStackName()); awsNetwork.setVpcId(createdCloudNetwork.getNetworkId()); awsNetwork.setSubnetMetas(createdCloudNetwork.getSubnets().stream() .collect(Collectors.toMap( CreatedSubnet::getSubnetId, subnet -> new CloudSubnet( subnet.getSubnetId(), subnet.getSubnetId(), subnet.getAvailabilityZone(), subnet.getCidr(), !subnet.isPublicSubnet(), subnet.isMapPublicIpOnLaunch(), subnet.isIgwAvailable(), subnet.getType()) ) ) ); return awsNetwork; } AwsEnvironmentNetworkConverter(EnvironmentViewConverter environmentViewConverter); @Override boolean isApplicableForDwx(CloudSubnet cloudSubnet); @Override boolean isApplicableForMlx(CloudSubnet cloudSubnet); @Override BaseNetwork setCreatedCloudNetwork(BaseNetwork baseNetwork, CreatedCloudNetwork createdCloudNetwork); @Override CloudPlatform getCloudPlatform(); @Override Network convertToNetwork(BaseNetwork baseNetwork); }
AwsEnvironmentNetworkConverter extends EnvironmentBaseNetworkConverter { @Override public BaseNetwork setCreatedCloudNetwork(BaseNetwork baseNetwork, CreatedCloudNetwork createdCloudNetwork) { AwsNetwork awsNetwork = (AwsNetwork) baseNetwork; awsNetwork.setName(createdCloudNetwork.getStackName()); awsNetwork.setVpcId(createdCloudNetwork.getNetworkId()); awsNetwork.setSubnetMetas(createdCloudNetwork.getSubnets().stream() .collect(Collectors.toMap( CreatedSubnet::getSubnetId, subnet -> new CloudSubnet( subnet.getSubnetId(), subnet.getSubnetId(), subnet.getAvailabilityZone(), subnet.getCidr(), !subnet.isPublicSubnet(), subnet.isMapPublicIpOnLaunch(), subnet.isIgwAvailable(), subnet.getType()) ) ) ); return awsNetwork; } AwsEnvironmentNetworkConverter(EnvironmentViewConverter environmentViewConverter); @Override boolean isApplicableForDwx(CloudSubnet cloudSubnet); @Override boolean isApplicableForMlx(CloudSubnet cloudSubnet); @Override BaseNetwork setCreatedCloudNetwork(BaseNetwork baseNetwork, CreatedCloudNetwork createdCloudNetwork); @Override CloudPlatform getCloudPlatform(); @Override Network convertToNetwork(BaseNetwork baseNetwork);  }