@Test void testProvideShouldCreateSubnets() { String networkCidr = "10.10.0.0/16"; Cidrs actual = underTest.provide(networkCidr, true); Assertions.assertEquals(NUMBER_OF_PRIVATE_SUBNETS, actual.getPrivateSubnets().size()); Assertions.assertEquals(NUMBER_OF_PUBLIC_SUBNETS, actual.getPublicSubnets().size()); Assertions.assertTrue(getCidrs(actual.getPublicSubnets()).contains("10.10.0.0/24")); Assertions.assertTrue(getCidrs(actual.getPublicSubnets()).contains("10.10.1.0/24")); Assertions.assertTrue(getCidrs(actual.getPublicSubnets()).contains("10.10.2.0/24")); Assertions.assertTrue(getCidrs(actual.getPrivateSubnets()).contains("10.10.160.0/19")); Assertions.assertTrue(getCidrs(actual.getPrivateSubnets()).contains("10.10.192.0/19")); Assertions.assertTrue(getCidrs(actual.getPrivateSubnets()).contains("10.10.224.0/19")); }
@Override public Cidrs provide(String networkCidr, boolean privateSubnetEnabled) { String[] ip = extendedSubnetTypeProvider.getIp(networkCidr); Set<NetworkSubnetRequest> publicSubnets = new HashSet<>(); Set<NetworkSubnetRequest> privateSubnets = new HashSet<>(); extendedSubnetTypeProvider.updateCidrAndAddToList(PUBLIC_SUBNET_IP_OFFSET, PUBLIC_SUBNET_IP_COUNT, PLUS_BITS_FOR_24_MASK, ip, publicSubnets, SubnetType.PUBLIC, PUBLIC_SUBNET_MASK); extendedSubnetTypeProvider.updateCidrAndAddToList(PRIVATE_SUBNET_IP_OFFSET, PRIVATE_SUBNET_IP_COUNT, PLUS_BITS_FOR_19_MASK, ip, privateSubnets, SubnetType.PRIVATE, PRIVATE_SUBNET_MASK); return cidrs(publicSubnets, privateSubnetEnabled ? privateSubnets : new HashSet<>()); }
AwsSubnetCidrProvider implements SubnetCidrProvider { @Override public Cidrs provide(String networkCidr, boolean privateSubnetEnabled) { String[] ip = extendedSubnetTypeProvider.getIp(networkCidr); Set<NetworkSubnetRequest> publicSubnets = new HashSet<>(); Set<NetworkSubnetRequest> privateSubnets = new HashSet<>(); extendedSubnetTypeProvider.updateCidrAndAddToList(PUBLIC_SUBNET_IP_OFFSET, PUBLIC_SUBNET_IP_COUNT, PLUS_BITS_FOR_24_MASK, ip, publicSubnets, SubnetType.PUBLIC, PUBLIC_SUBNET_MASK); extendedSubnetTypeProvider.updateCidrAndAddToList(PRIVATE_SUBNET_IP_OFFSET, PRIVATE_SUBNET_IP_COUNT, PLUS_BITS_FOR_19_MASK, ip, privateSubnets, SubnetType.PRIVATE, PRIVATE_SUBNET_MASK); return cidrs(publicSubnets, privateSubnetEnabled ? privateSubnets : new HashSet<>()); } }
AwsSubnetCidrProvider implements SubnetCidrProvider { @Override public Cidrs provide(String networkCidr, boolean privateSubnetEnabled) { String[] ip = extendedSubnetTypeProvider.getIp(networkCidr); Set<NetworkSubnetRequest> publicSubnets = new HashSet<>(); Set<NetworkSubnetRequest> privateSubnets = new HashSet<>(); extendedSubnetTypeProvider.updateCidrAndAddToList(PUBLIC_SUBNET_IP_OFFSET, PUBLIC_SUBNET_IP_COUNT, PLUS_BITS_FOR_24_MASK, ip, publicSubnets, SubnetType.PUBLIC, PUBLIC_SUBNET_MASK); extendedSubnetTypeProvider.updateCidrAndAddToList(PRIVATE_SUBNET_IP_OFFSET, PRIVATE_SUBNET_IP_COUNT, PLUS_BITS_FOR_19_MASK, ip, privateSubnets, SubnetType.PRIVATE, PRIVATE_SUBNET_MASK); return cidrs(publicSubnets, privateSubnetEnabled ? privateSubnets : new HashSet<>()); } AwsSubnetCidrProvider(ExtendedSubnetTypeProvider extendedSubnetTypeProvider); }
AwsSubnetCidrProvider implements SubnetCidrProvider { @Override public Cidrs provide(String networkCidr, boolean privateSubnetEnabled) { String[] ip = extendedSubnetTypeProvider.getIp(networkCidr); Set<NetworkSubnetRequest> publicSubnets = new HashSet<>(); Set<NetworkSubnetRequest> privateSubnets = new HashSet<>(); extendedSubnetTypeProvider.updateCidrAndAddToList(PUBLIC_SUBNET_IP_OFFSET, PUBLIC_SUBNET_IP_COUNT, PLUS_BITS_FOR_24_MASK, ip, publicSubnets, SubnetType.PUBLIC, PUBLIC_SUBNET_MASK); extendedSubnetTypeProvider.updateCidrAndAddToList(PRIVATE_SUBNET_IP_OFFSET, PRIVATE_SUBNET_IP_COUNT, PLUS_BITS_FOR_19_MASK, ip, privateSubnets, SubnetType.PRIVATE, PRIVATE_SUBNET_MASK); return cidrs(publicSubnets, privateSubnetEnabled ? privateSubnets : new HashSet<>()); } AwsSubnetCidrProvider(ExtendedSubnetTypeProvider extendedSubnetTypeProvider); @Override Cidrs provide(String networkCidr, boolean privateSubnetEnabled); @Override String cloudPlatform(); }
AwsSubnetCidrProvider implements SubnetCidrProvider { @Override public Cidrs provide(String networkCidr, boolean privateSubnetEnabled) { String[] ip = extendedSubnetTypeProvider.getIp(networkCidr); Set<NetworkSubnetRequest> publicSubnets = new HashSet<>(); Set<NetworkSubnetRequest> privateSubnets = new HashSet<>(); extendedSubnetTypeProvider.updateCidrAndAddToList(PUBLIC_SUBNET_IP_OFFSET, PUBLIC_SUBNET_IP_COUNT, PLUS_BITS_FOR_24_MASK, ip, publicSubnets, SubnetType.PUBLIC, PUBLIC_SUBNET_MASK); extendedSubnetTypeProvider.updateCidrAndAddToList(PRIVATE_SUBNET_IP_OFFSET, PRIVATE_SUBNET_IP_COUNT, PLUS_BITS_FOR_19_MASK, ip, privateSubnets, SubnetType.PRIVATE, PRIVATE_SUBNET_MASK); return cidrs(publicSubnets, privateSubnetEnabled ? privateSubnets : new HashSet<>()); } AwsSubnetCidrProvider(ExtendedSubnetTypeProvider extendedSubnetTypeProvider); @Override Cidrs provide(String networkCidr, boolean privateSubnetEnabled); @Override String cloudPlatform();  }