@Test public void testConvertShouldRCallTheParserWhenTheStackStackContainsNetworkRelatedResources() throws JsonProcessingException { Resource vpc = new Resource(); vpc.setResourceType(ResourceType.AWS_VPC); vpc.setResourceName("idOfTheCreatedVPC"); Resource subnet = new Resource(); subnet.setResourceType(ResourceType.AWS_SUBNET); subnet.setResourceName("idOfTheCreatedSubnet"); Resource azureNetwork = new Resource(); azureNetwork.setResourceType(ResourceType.AZURE_NETWORK); azureNetwork.setResourceName("idOfTheCreatedAzureNetwork"); when(stack.getResources()).thenReturn(Set.of(vpc, subnet, azureNetwork)); when(stack.getNetwork()).thenReturn(network); Map<String, Object> attributes = Map.of("cloudPlatform", "MOCK"); when(network.getAttributes()).thenReturn(new Json(attributes)); when(network.getSubnetCIDR()).thenReturn(DEFAULT_CIDR); NetworkV4Response result = underTest.convert(stack); Map<String, Object> expectedParameters = new HashMap<>(attributes); expectedParameters.put("vpcId", vpc.getResourceName()); expectedParameters.put("subnetId", subnet.getResourceName()); expectedParameters.put("networkId", azureNetwork.getResourceName()); verify(providerParameterCalculator).parse(eq(expectedParameters), any()); assertNotNull(result); assertEquals(DEFAULT_CIDR, result.getSubnetCIDR()); }
@Override public NetworkV4Response convert(Stack source) { NetworkV4Response networkResp = null; Network network = source.getNetwork(); if (network != null) { networkResp = new NetworkV4Response(); networkResp.setSubnetCIDR(network.getSubnetCIDR()); if (network.getAttributes() != null) { Map<String, Object> parameters = cleanMap(network.getAttributes().getMap()); putNetworkResourcesIntoResponse(source, parameters); providerParameterCalculator.parse(parameters, networkResp); } } return networkResp; }
NetworkToNetworkV4ResponseConverter extends AbstractConversionServiceAwareConverter<Stack, NetworkV4Response> { @Override public NetworkV4Response convert(Stack source) { NetworkV4Response networkResp = null; Network network = source.getNetwork(); if (network != null) { networkResp = new NetworkV4Response(); networkResp.setSubnetCIDR(network.getSubnetCIDR()); if (network.getAttributes() != null) { Map<String, Object> parameters = cleanMap(network.getAttributes().getMap()); putNetworkResourcesIntoResponse(source, parameters); providerParameterCalculator.parse(parameters, networkResp); } } return networkResp; } }
NetworkToNetworkV4ResponseConverter extends AbstractConversionServiceAwareConverter<Stack, NetworkV4Response> { @Override public NetworkV4Response convert(Stack source) { NetworkV4Response networkResp = null; Network network = source.getNetwork(); if (network != null) { networkResp = new NetworkV4Response(); networkResp.setSubnetCIDR(network.getSubnetCIDR()); if (network.getAttributes() != null) { Map<String, Object> parameters = cleanMap(network.getAttributes().getMap()); putNetworkResourcesIntoResponse(source, parameters); providerParameterCalculator.parse(parameters, networkResp); } } return networkResp; }  }
NetworkToNetworkV4ResponseConverter extends AbstractConversionServiceAwareConverter<Stack, NetworkV4Response> { @Override public NetworkV4Response convert(Stack source) { NetworkV4Response networkResp = null; Network network = source.getNetwork(); if (network != null) { networkResp = new NetworkV4Response(); networkResp.setSubnetCIDR(network.getSubnetCIDR()); if (network.getAttributes() != null) { Map<String, Object> parameters = cleanMap(network.getAttributes().getMap()); putNetworkResourcesIntoResponse(source, parameters); providerParameterCalculator.parse(parameters, networkResp); } } return networkResp; }  @Override NetworkV4Response convert(Stack source); }
NetworkToNetworkV4ResponseConverter extends AbstractConversionServiceAwareConverter<Stack, NetworkV4Response> { @Override public NetworkV4Response convert(Stack source) { NetworkV4Response networkResp = null; Network network = source.getNetwork(); if (network != null) { networkResp = new NetworkV4Response(); networkResp.setSubnetCIDR(network.getSubnetCIDR()); if (network.getAttributes() != null) { Map<String, Object> parameters = cleanMap(network.getAttributes().getMap()); putNetworkResourcesIntoResponse(source, parameters); providerParameterCalculator.parse(parameters, networkResp); } } return networkResp; }  @Override NetworkV4Response convert(Stack source);  }