@Test void testConvertWithAzureParams() { NetworkDto network = createNetworkDto().withAzure(createAzureParams()).build(); when(subnetIdProvider.provide(network, TUNNEL, network.getCloudPlatform())).thenReturn(PREFERRED_SUBNET_ID); EnvironmentNetworkResponse actual = underTest.convert(network, TUNNEL, true); assertCommonFields(network, actual); assertEquals(network.getAzure().isNoPublicIp(), actual.getAzure().getNoPublicIp()); assertEquals(network.getAzure().getNetworkId(), actual.getAzure().getNetworkId()); assertEquals(network.getAzure().getResourceGroupName(), actual.getAzure().getResourceGroupName()); assertNull(actual.getAws()); assertNull(actual.getYarn()); assertNull(actual.getMock()); }
public EnvironmentNetworkResponse convert(NetworkDto network, Tunnel tunnel, boolean detailedResponse) { return EnvironmentNetworkResponse.EnvironmentNetworkResponseBuilder.anEnvironmentNetworkResponse() .withCrn(network.getResourceCrn()) .withSubnetIds(network.getSubnetIds()) .withNetworkCidr(network.getNetworkCidr()) .withNetworkCidrs(network.getNetworkCidrs()) .withSubnetMetas(network.getSubnetMetas()) .withCbSubnets(network.getCbSubnets()) .withDwxSubnets(network.getDwxSubnets()) .withMlxSubnets(network.getMlxSubnets()) .withLiftieSubnets(network.getMlxSubnets()) .withPreferedSubnetId(getPreferedSubnetId(network, tunnel, detailedResponse)) .withPrivateSubnetCreation(network.getPrivateSubnetCreation()) .withServiceEndpointCreation(network.getServiceEndpointCreation()) .withOutboundInternetTraffic(network.getOutboundInternetTraffic()) .withExistingNetwork(RegistrationType.EXISTING == network.getRegistrationType()) .withAws(getIfNotNull(network.getAws(), p -> EnvironmentNetworkAwsParams.EnvironmentNetworkAwsParamsBuilder .anEnvironmentNetworkAwsParams() .withVpcId(p.getVpcId()) .build())) .withAzure(getIfNotNull(network.getAzure(), p -> EnvironmentNetworkAzureParams.EnvironmentNetworkAzureParamsBuilder .anEnvironmentNetworkAzureParams() .withNetworkId(p.getNetworkId()) .withResourceGroupName(p.getResourceGroupName()) .withNoPublicIp(p.isNoPublicIp()) .build())) .withGcp(getIfNotNull(network.getGcp(), p -> EnvironmentNetworkGcpParams.EnvironmentNetworkGcpParamsBuilder .anEnvironmentNetworkGcpParamsBuilder() .withNetworkId(p.getNetworkId()) .withSharedProjectId(p.getSharedProjectId()) .withNoFirewallRules(p.getNoFirewallRules()) .withNoPublicIp(p.getNoPublicIp()) .build())) .withYarn(getIfNotNull(network.getYarn(), p -> EnvironmentNetworkYarnParams.EnvironmentNetworkYarnParamsBuilder .anEnvironmentNetworkYarnParams() .withQueue(p.getQueue()) .withLifetime(p.getLifetime()) .build())) .withMock(getIfNotNull(network.getMock(), p -> EnvironmentNetworkMockParams.EnvironmentNetworkMockParamsBuilder .anEnvironmentNetworkMockParams() .withVpcId(p.getVpcId()) .withInternetGatewayId(p.getInternetGatewayId()) .build())) .build(); }
NetworkDtoToResponseConverter { public EnvironmentNetworkResponse convert(NetworkDto network, Tunnel tunnel, boolean detailedResponse) { return EnvironmentNetworkResponse.EnvironmentNetworkResponseBuilder.anEnvironmentNetworkResponse() .withCrn(network.getResourceCrn()) .withSubnetIds(network.getSubnetIds()) .withNetworkCidr(network.getNetworkCidr()) .withNetworkCidrs(network.getNetworkCidrs()) .withSubnetMetas(network.getSubnetMetas()) .withCbSubnets(network.getCbSubnets()) .withDwxSubnets(network.getDwxSubnets()) .withMlxSubnets(network.getMlxSubnets()) .withLiftieSubnets(network.getMlxSubnets()) .withPreferedSubnetId(getPreferedSubnetId(network, tunnel, detailedResponse)) .withPrivateSubnetCreation(network.getPrivateSubnetCreation()) .withServiceEndpointCreation(network.getServiceEndpointCreation()) .withOutboundInternetTraffic(network.getOutboundInternetTraffic()) .withExistingNetwork(RegistrationType.EXISTING == network.getRegistrationType()) .withAws(getIfNotNull(network.getAws(), p -> EnvironmentNetworkAwsParams.EnvironmentNetworkAwsParamsBuilder .anEnvironmentNetworkAwsParams() .withVpcId(p.getVpcId()) .build())) .withAzure(getIfNotNull(network.getAzure(), p -> EnvironmentNetworkAzureParams.EnvironmentNetworkAzureParamsBuilder .anEnvironmentNetworkAzureParams() .withNetworkId(p.getNetworkId()) .withResourceGroupName(p.getResourceGroupName()) .withNoPublicIp(p.isNoPublicIp()) .build())) .withGcp(getIfNotNull(network.getGcp(), p -> EnvironmentNetworkGcpParams.EnvironmentNetworkGcpParamsBuilder .anEnvironmentNetworkGcpParamsBuilder() .withNetworkId(p.getNetworkId()) .withSharedProjectId(p.getSharedProjectId()) .withNoFirewallRules(p.getNoFirewallRules()) .withNoPublicIp(p.getNoPublicIp()) .build())) .withYarn(getIfNotNull(network.getYarn(), p -> EnvironmentNetworkYarnParams.EnvironmentNetworkYarnParamsBuilder .anEnvironmentNetworkYarnParams() .withQueue(p.getQueue()) .withLifetime(p.getLifetime()) .build())) .withMock(getIfNotNull(network.getMock(), p -> EnvironmentNetworkMockParams.EnvironmentNetworkMockParamsBuilder .anEnvironmentNetworkMockParams() .withVpcId(p.getVpcId()) .withInternetGatewayId(p.getInternetGatewayId()) .build())) .build(); } }
NetworkDtoToResponseConverter { public EnvironmentNetworkResponse convert(NetworkDto network, Tunnel tunnel, boolean detailedResponse) { return EnvironmentNetworkResponse.EnvironmentNetworkResponseBuilder.anEnvironmentNetworkResponse() .withCrn(network.getResourceCrn()) .withSubnetIds(network.getSubnetIds()) .withNetworkCidr(network.getNetworkCidr()) .withNetworkCidrs(network.getNetworkCidrs()) .withSubnetMetas(network.getSubnetMetas()) .withCbSubnets(network.getCbSubnets()) .withDwxSubnets(network.getDwxSubnets()) .withMlxSubnets(network.getMlxSubnets()) .withLiftieSubnets(network.getMlxSubnets()) .withPreferedSubnetId(getPreferedSubnetId(network, tunnel, detailedResponse)) .withPrivateSubnetCreation(network.getPrivateSubnetCreation()) .withServiceEndpointCreation(network.getServiceEndpointCreation()) .withOutboundInternetTraffic(network.getOutboundInternetTraffic()) .withExistingNetwork(RegistrationType.EXISTING == network.getRegistrationType()) .withAws(getIfNotNull(network.getAws(), p -> EnvironmentNetworkAwsParams.EnvironmentNetworkAwsParamsBuilder .anEnvironmentNetworkAwsParams() .withVpcId(p.getVpcId()) .build())) .withAzure(getIfNotNull(network.getAzure(), p -> EnvironmentNetworkAzureParams.EnvironmentNetworkAzureParamsBuilder .anEnvironmentNetworkAzureParams() .withNetworkId(p.getNetworkId()) .withResourceGroupName(p.getResourceGroupName()) .withNoPublicIp(p.isNoPublicIp()) .build())) .withGcp(getIfNotNull(network.getGcp(), p -> EnvironmentNetworkGcpParams.EnvironmentNetworkGcpParamsBuilder .anEnvironmentNetworkGcpParamsBuilder() .withNetworkId(p.getNetworkId()) .withSharedProjectId(p.getSharedProjectId()) .withNoFirewallRules(p.getNoFirewallRules()) .withNoPublicIp(p.getNoPublicIp()) .build())) .withYarn(getIfNotNull(network.getYarn(), p -> EnvironmentNetworkYarnParams.EnvironmentNetworkYarnParamsBuilder .anEnvironmentNetworkYarnParams() .withQueue(p.getQueue()) .withLifetime(p.getLifetime()) .build())) .withMock(getIfNotNull(network.getMock(), p -> EnvironmentNetworkMockParams.EnvironmentNetworkMockParamsBuilder .anEnvironmentNetworkMockParams() .withVpcId(p.getVpcId()) .withInternetGatewayId(p.getInternetGatewayId()) .build())) .build(); } NetworkDtoToResponseConverter(SubnetIdProvider subnetIdProvider); }
NetworkDtoToResponseConverter { public EnvironmentNetworkResponse convert(NetworkDto network, Tunnel tunnel, boolean detailedResponse) { return EnvironmentNetworkResponse.EnvironmentNetworkResponseBuilder.anEnvironmentNetworkResponse() .withCrn(network.getResourceCrn()) .withSubnetIds(network.getSubnetIds()) .withNetworkCidr(network.getNetworkCidr()) .withNetworkCidrs(network.getNetworkCidrs()) .withSubnetMetas(network.getSubnetMetas()) .withCbSubnets(network.getCbSubnets()) .withDwxSubnets(network.getDwxSubnets()) .withMlxSubnets(network.getMlxSubnets()) .withLiftieSubnets(network.getMlxSubnets()) .withPreferedSubnetId(getPreferedSubnetId(network, tunnel, detailedResponse)) .withPrivateSubnetCreation(network.getPrivateSubnetCreation()) .withServiceEndpointCreation(network.getServiceEndpointCreation()) .withOutboundInternetTraffic(network.getOutboundInternetTraffic()) .withExistingNetwork(RegistrationType.EXISTING == network.getRegistrationType()) .withAws(getIfNotNull(network.getAws(), p -> EnvironmentNetworkAwsParams.EnvironmentNetworkAwsParamsBuilder .anEnvironmentNetworkAwsParams() .withVpcId(p.getVpcId()) .build())) .withAzure(getIfNotNull(network.getAzure(), p -> EnvironmentNetworkAzureParams.EnvironmentNetworkAzureParamsBuilder .anEnvironmentNetworkAzureParams() .withNetworkId(p.getNetworkId()) .withResourceGroupName(p.getResourceGroupName()) .withNoPublicIp(p.isNoPublicIp()) .build())) .withGcp(getIfNotNull(network.getGcp(), p -> EnvironmentNetworkGcpParams.EnvironmentNetworkGcpParamsBuilder .anEnvironmentNetworkGcpParamsBuilder() .withNetworkId(p.getNetworkId()) .withSharedProjectId(p.getSharedProjectId()) .withNoFirewallRules(p.getNoFirewallRules()) .withNoPublicIp(p.getNoPublicIp()) .build())) .withYarn(getIfNotNull(network.getYarn(), p -> EnvironmentNetworkYarnParams.EnvironmentNetworkYarnParamsBuilder .anEnvironmentNetworkYarnParams() .withQueue(p.getQueue()) .withLifetime(p.getLifetime()) .build())) .withMock(getIfNotNull(network.getMock(), p -> EnvironmentNetworkMockParams.EnvironmentNetworkMockParamsBuilder .anEnvironmentNetworkMockParams() .withVpcId(p.getVpcId()) .withInternetGatewayId(p.getInternetGatewayId()) .build())) .build(); } NetworkDtoToResponseConverter(SubnetIdProvider subnetIdProvider); EnvironmentNetworkResponse convert(NetworkDto network, Tunnel tunnel, boolean detailedResponse); String getPreferedSubnetId(NetworkDto network, Tunnel tunnel, boolean detailedResponse); }
NetworkDtoToResponseConverter { public EnvironmentNetworkResponse convert(NetworkDto network, Tunnel tunnel, boolean detailedResponse) { return EnvironmentNetworkResponse.EnvironmentNetworkResponseBuilder.anEnvironmentNetworkResponse() .withCrn(network.getResourceCrn()) .withSubnetIds(network.getSubnetIds()) .withNetworkCidr(network.getNetworkCidr()) .withNetworkCidrs(network.getNetworkCidrs()) .withSubnetMetas(network.getSubnetMetas()) .withCbSubnets(network.getCbSubnets()) .withDwxSubnets(network.getDwxSubnets()) .withMlxSubnets(network.getMlxSubnets()) .withLiftieSubnets(network.getMlxSubnets()) .withPreferedSubnetId(getPreferedSubnetId(network, tunnel, detailedResponse)) .withPrivateSubnetCreation(network.getPrivateSubnetCreation()) .withServiceEndpointCreation(network.getServiceEndpointCreation()) .withOutboundInternetTraffic(network.getOutboundInternetTraffic()) .withExistingNetwork(RegistrationType.EXISTING == network.getRegistrationType()) .withAws(getIfNotNull(network.getAws(), p -> EnvironmentNetworkAwsParams.EnvironmentNetworkAwsParamsBuilder .anEnvironmentNetworkAwsParams() .withVpcId(p.getVpcId()) .build())) .withAzure(getIfNotNull(network.getAzure(), p -> EnvironmentNetworkAzureParams.EnvironmentNetworkAzureParamsBuilder .anEnvironmentNetworkAzureParams() .withNetworkId(p.getNetworkId()) .withResourceGroupName(p.getResourceGroupName()) .withNoPublicIp(p.isNoPublicIp()) .build())) .withGcp(getIfNotNull(network.getGcp(), p -> EnvironmentNetworkGcpParams.EnvironmentNetworkGcpParamsBuilder .anEnvironmentNetworkGcpParamsBuilder() .withNetworkId(p.getNetworkId()) .withSharedProjectId(p.getSharedProjectId()) .withNoFirewallRules(p.getNoFirewallRules()) .withNoPublicIp(p.getNoPublicIp()) .build())) .withYarn(getIfNotNull(network.getYarn(), p -> EnvironmentNetworkYarnParams.EnvironmentNetworkYarnParamsBuilder .anEnvironmentNetworkYarnParams() .withQueue(p.getQueue()) .withLifetime(p.getLifetime()) .build())) .withMock(getIfNotNull(network.getMock(), p -> EnvironmentNetworkMockParams.EnvironmentNetworkMockParamsBuilder .anEnvironmentNetworkMockParams() .withVpcId(p.getVpcId()) .withInternetGatewayId(p.getInternetGatewayId()) .build())) .build(); } NetworkDtoToResponseConverter(SubnetIdProvider subnetIdProvider); EnvironmentNetworkResponse convert(NetworkDto network, Tunnel tunnel, boolean detailedResponse); String getPreferedSubnetId(NetworkDto network, Tunnel tunnel, boolean detailedResponse);  }