@Test void testConvertMock() { EnvironmentNetworkRequest network = createNetworkRequest(); network.setMock(createMockParams()); NetworkDto actual = underTest.convert(network); assertEquals(network.getMock().getVpcId(), actual.getMock().getVpcId()); assertEquals(network.getMock().getInternetGatewayId(), actual.getMock().getInternetGatewayId()); assertCommonFields(network, actual); }
public NetworkDto convert(EnvironmentNetworkRequest network) { LOGGER.debug("Converting network request to dto"); NetworkDto.Builder builder = NetworkDto.builder(); if (network.getAws() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "AWS"); AwsParams awsParams = new AwsParams(); awsParams.setVpcId(network.getAws().getVpcId()); builder.withAws(awsParams); builder.withNetworkId(network.getAws().getVpcId()); } if (network.getAzure() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "Azure"); AzureParams azureParams = new AzureParams(); azureParams.setNetworkId(network.getAzure().getNetworkId()); azureParams.setNoPublicIp(Boolean.TRUE.equals(network.getAzure().getNoPublicIp())); azureParams.setResourceGroupName(network.getAzure().getResourceGroupName()); builder.withAzure(azureParams); builder.withNetworkId(network.getAzure().getNetworkId()); } if (network.getGcp() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "GCP"); GcpParams gcpParams = new GcpParams(); gcpParams.setNetworkId(network.getGcp().getNetworkId()); gcpParams.setSharedProjectId(network.getGcp().getSharedProjectId()); gcpParams.setNoFirewallRules(network.getGcp().getNoFirewallRules()); gcpParams.setNoPublicIp(network.getGcp().getNoPublicIp()); builder.withGcp(gcpParams); builder.withNetworkId(network.getGcp().getNetworkId()); } if (network.getYarn() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "Yarn"); YarnParams yarnParams = new YarnParams(); yarnParams.setQueue(network.getYarn().getQueue()); yarnParams.setLifetime(network.getYarn().getLifetime()); builder.withYarn(yarnParams); } if (network.getMock() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "Mock"); MockParams mockParams = new MockParams(); mockParams.setInternetGatewayId(network.getMock().getInternetGatewayId()); mockParams.setVpcId(network.getMock().getVpcId()); builder.withMock(mockParams); builder.withNetworkId(mockParams.getVpcId()); } if (network.getGcp() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "Gcp"); GcpParams gcpParams = new GcpParams(); gcpParams.setSharedProjectId(network.getGcp().getSharedProjectId()); gcpParams.setNetworkId(network.getGcp().getNetworkId()); gcpParams.setNoFirewallRules(Boolean.TRUE.equals(network.getGcp().getNoFirewallRules())); gcpParams.setNoPublicIp(Boolean.TRUE.equals(network.getGcp().getNoPublicIp())); builder.withGcp(gcpParams); builder.withNetworkId(gcpParams.getNetworkId()); } if (network.getSubnetIds() != null) { builder.withSubnetMetas(network.getSubnetIds().stream() .collect(Collectors.toMap(id -> id, id -> new CloudSubnet(id, id)))); } return builder .withNetworkCidr(network.getNetworkCidr()) .withNetworkCidrs(getNetworkCidrs(network)) .withPrivateSubnetCreation(getPrivateSubnetCreation(network)) .withServiceEndpointCreation(getServiceEndpointCreation(network)) .withOutboundInternetTraffic(getOutboundInternetTraffic(network)) .build(); }
NetworkRequestToDtoConverter { public NetworkDto convert(EnvironmentNetworkRequest network) { LOGGER.debug("Converting network request to dto"); NetworkDto.Builder builder = NetworkDto.builder(); if (network.getAws() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "AWS"); AwsParams awsParams = new AwsParams(); awsParams.setVpcId(network.getAws().getVpcId()); builder.withAws(awsParams); builder.withNetworkId(network.getAws().getVpcId()); } if (network.getAzure() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "Azure"); AzureParams azureParams = new AzureParams(); azureParams.setNetworkId(network.getAzure().getNetworkId()); azureParams.setNoPublicIp(Boolean.TRUE.equals(network.getAzure().getNoPublicIp())); azureParams.setResourceGroupName(network.getAzure().getResourceGroupName()); builder.withAzure(azureParams); builder.withNetworkId(network.getAzure().getNetworkId()); } if (network.getGcp() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "GCP"); GcpParams gcpParams = new GcpParams(); gcpParams.setNetworkId(network.getGcp().getNetworkId()); gcpParams.setSharedProjectId(network.getGcp().getSharedProjectId()); gcpParams.setNoFirewallRules(network.getGcp().getNoFirewallRules()); gcpParams.setNoPublicIp(network.getGcp().getNoPublicIp()); builder.withGcp(gcpParams); builder.withNetworkId(network.getGcp().getNetworkId()); } if (network.getYarn() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "Yarn"); YarnParams yarnParams = new YarnParams(); yarnParams.setQueue(network.getYarn().getQueue()); yarnParams.setLifetime(network.getYarn().getLifetime()); builder.withYarn(yarnParams); } if (network.getMock() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "Mock"); MockParams mockParams = new MockParams(); mockParams.setInternetGatewayId(network.getMock().getInternetGatewayId()); mockParams.setVpcId(network.getMock().getVpcId()); builder.withMock(mockParams); builder.withNetworkId(mockParams.getVpcId()); } if (network.getGcp() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "Gcp"); GcpParams gcpParams = new GcpParams(); gcpParams.setSharedProjectId(network.getGcp().getSharedProjectId()); gcpParams.setNetworkId(network.getGcp().getNetworkId()); gcpParams.setNoFirewallRules(Boolean.TRUE.equals(network.getGcp().getNoFirewallRules())); gcpParams.setNoPublicIp(Boolean.TRUE.equals(network.getGcp().getNoPublicIp())); builder.withGcp(gcpParams); builder.withNetworkId(gcpParams.getNetworkId()); } if (network.getSubnetIds() != null) { builder.withSubnetMetas(network.getSubnetIds().stream() .collect(Collectors.toMap(id -> id, id -> new CloudSubnet(id, id)))); } return builder .withNetworkCidr(network.getNetworkCidr()) .withNetworkCidrs(getNetworkCidrs(network)) .withPrivateSubnetCreation(getPrivateSubnetCreation(network)) .withServiceEndpointCreation(getServiceEndpointCreation(network)) .withOutboundInternetTraffic(getOutboundInternetTraffic(network)) .build(); } }
NetworkRequestToDtoConverter { public NetworkDto convert(EnvironmentNetworkRequest network) { LOGGER.debug("Converting network request to dto"); NetworkDto.Builder builder = NetworkDto.builder(); if (network.getAws() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "AWS"); AwsParams awsParams = new AwsParams(); awsParams.setVpcId(network.getAws().getVpcId()); builder.withAws(awsParams); builder.withNetworkId(network.getAws().getVpcId()); } if (network.getAzure() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "Azure"); AzureParams azureParams = new AzureParams(); azureParams.setNetworkId(network.getAzure().getNetworkId()); azureParams.setNoPublicIp(Boolean.TRUE.equals(network.getAzure().getNoPublicIp())); azureParams.setResourceGroupName(network.getAzure().getResourceGroupName()); builder.withAzure(azureParams); builder.withNetworkId(network.getAzure().getNetworkId()); } if (network.getGcp() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "GCP"); GcpParams gcpParams = new GcpParams(); gcpParams.setNetworkId(network.getGcp().getNetworkId()); gcpParams.setSharedProjectId(network.getGcp().getSharedProjectId()); gcpParams.setNoFirewallRules(network.getGcp().getNoFirewallRules()); gcpParams.setNoPublicIp(network.getGcp().getNoPublicIp()); builder.withGcp(gcpParams); builder.withNetworkId(network.getGcp().getNetworkId()); } if (network.getYarn() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "Yarn"); YarnParams yarnParams = new YarnParams(); yarnParams.setQueue(network.getYarn().getQueue()); yarnParams.setLifetime(network.getYarn().getLifetime()); builder.withYarn(yarnParams); } if (network.getMock() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "Mock"); MockParams mockParams = new MockParams(); mockParams.setInternetGatewayId(network.getMock().getInternetGatewayId()); mockParams.setVpcId(network.getMock().getVpcId()); builder.withMock(mockParams); builder.withNetworkId(mockParams.getVpcId()); } if (network.getGcp() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "Gcp"); GcpParams gcpParams = new GcpParams(); gcpParams.setSharedProjectId(network.getGcp().getSharedProjectId()); gcpParams.setNetworkId(network.getGcp().getNetworkId()); gcpParams.setNoFirewallRules(Boolean.TRUE.equals(network.getGcp().getNoFirewallRules())); gcpParams.setNoPublicIp(Boolean.TRUE.equals(network.getGcp().getNoPublicIp())); builder.withGcp(gcpParams); builder.withNetworkId(gcpParams.getNetworkId()); } if (network.getSubnetIds() != null) { builder.withSubnetMetas(network.getSubnetIds().stream() .collect(Collectors.toMap(id -> id, id -> new CloudSubnet(id, id)))); } return builder .withNetworkCidr(network.getNetworkCidr()) .withNetworkCidrs(getNetworkCidrs(network)) .withPrivateSubnetCreation(getPrivateSubnetCreation(network)) .withServiceEndpointCreation(getServiceEndpointCreation(network)) .withOutboundInternetTraffic(getOutboundInternetTraffic(network)) .build(); }  }
NetworkRequestToDtoConverter { public NetworkDto convert(EnvironmentNetworkRequest network) { LOGGER.debug("Converting network request to dto"); NetworkDto.Builder builder = NetworkDto.builder(); if (network.getAws() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "AWS"); AwsParams awsParams = new AwsParams(); awsParams.setVpcId(network.getAws().getVpcId()); builder.withAws(awsParams); builder.withNetworkId(network.getAws().getVpcId()); } if (network.getAzure() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "Azure"); AzureParams azureParams = new AzureParams(); azureParams.setNetworkId(network.getAzure().getNetworkId()); azureParams.setNoPublicIp(Boolean.TRUE.equals(network.getAzure().getNoPublicIp())); azureParams.setResourceGroupName(network.getAzure().getResourceGroupName()); builder.withAzure(azureParams); builder.withNetworkId(network.getAzure().getNetworkId()); } if (network.getGcp() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "GCP"); GcpParams gcpParams = new GcpParams(); gcpParams.setNetworkId(network.getGcp().getNetworkId()); gcpParams.setSharedProjectId(network.getGcp().getSharedProjectId()); gcpParams.setNoFirewallRules(network.getGcp().getNoFirewallRules()); gcpParams.setNoPublicIp(network.getGcp().getNoPublicIp()); builder.withGcp(gcpParams); builder.withNetworkId(network.getGcp().getNetworkId()); } if (network.getYarn() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "Yarn"); YarnParams yarnParams = new YarnParams(); yarnParams.setQueue(network.getYarn().getQueue()); yarnParams.setLifetime(network.getYarn().getLifetime()); builder.withYarn(yarnParams); } if (network.getMock() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "Mock"); MockParams mockParams = new MockParams(); mockParams.setInternetGatewayId(network.getMock().getInternetGatewayId()); mockParams.setVpcId(network.getMock().getVpcId()); builder.withMock(mockParams); builder.withNetworkId(mockParams.getVpcId()); } if (network.getGcp() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "Gcp"); GcpParams gcpParams = new GcpParams(); gcpParams.setSharedProjectId(network.getGcp().getSharedProjectId()); gcpParams.setNetworkId(network.getGcp().getNetworkId()); gcpParams.setNoFirewallRules(Boolean.TRUE.equals(network.getGcp().getNoFirewallRules())); gcpParams.setNoPublicIp(Boolean.TRUE.equals(network.getGcp().getNoPublicIp())); builder.withGcp(gcpParams); builder.withNetworkId(gcpParams.getNetworkId()); } if (network.getSubnetIds() != null) { builder.withSubnetMetas(network.getSubnetIds().stream() .collect(Collectors.toMap(id -> id, id -> new CloudSubnet(id, id)))); } return builder .withNetworkCidr(network.getNetworkCidr()) .withNetworkCidrs(getNetworkCidrs(network)) .withPrivateSubnetCreation(getPrivateSubnetCreation(network)) .withServiceEndpointCreation(getServiceEndpointCreation(network)) .withOutboundInternetTraffic(getOutboundInternetTraffic(network)) .build(); }  NetworkDto convert(EnvironmentNetworkRequest network); }
NetworkRequestToDtoConverter { public NetworkDto convert(EnvironmentNetworkRequest network) { LOGGER.debug("Converting network request to dto"); NetworkDto.Builder builder = NetworkDto.builder(); if (network.getAws() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "AWS"); AwsParams awsParams = new AwsParams(); awsParams.setVpcId(network.getAws().getVpcId()); builder.withAws(awsParams); builder.withNetworkId(network.getAws().getVpcId()); } if (network.getAzure() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "Azure"); AzureParams azureParams = new AzureParams(); azureParams.setNetworkId(network.getAzure().getNetworkId()); azureParams.setNoPublicIp(Boolean.TRUE.equals(network.getAzure().getNoPublicIp())); azureParams.setResourceGroupName(network.getAzure().getResourceGroupName()); builder.withAzure(azureParams); builder.withNetworkId(network.getAzure().getNetworkId()); } if (network.getGcp() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "GCP"); GcpParams gcpParams = new GcpParams(); gcpParams.setNetworkId(network.getGcp().getNetworkId()); gcpParams.setSharedProjectId(network.getGcp().getSharedProjectId()); gcpParams.setNoFirewallRules(network.getGcp().getNoFirewallRules()); gcpParams.setNoPublicIp(network.getGcp().getNoPublicIp()); builder.withGcp(gcpParams); builder.withNetworkId(network.getGcp().getNetworkId()); } if (network.getYarn() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "Yarn"); YarnParams yarnParams = new YarnParams(); yarnParams.setQueue(network.getYarn().getQueue()); yarnParams.setLifetime(network.getYarn().getLifetime()); builder.withYarn(yarnParams); } if (network.getMock() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "Mock"); MockParams mockParams = new MockParams(); mockParams.setInternetGatewayId(network.getMock().getInternetGatewayId()); mockParams.setVpcId(network.getMock().getVpcId()); builder.withMock(mockParams); builder.withNetworkId(mockParams.getVpcId()); } if (network.getGcp() != null) { LOGGER.debug(NETWORK_CONVERT_MESSAGE_TEMPLATE, "Gcp"); GcpParams gcpParams = new GcpParams(); gcpParams.setSharedProjectId(network.getGcp().getSharedProjectId()); gcpParams.setNetworkId(network.getGcp().getNetworkId()); gcpParams.setNoFirewallRules(Boolean.TRUE.equals(network.getGcp().getNoFirewallRules())); gcpParams.setNoPublicIp(Boolean.TRUE.equals(network.getGcp().getNoPublicIp())); builder.withGcp(gcpParams); builder.withNetworkId(gcpParams.getNetworkId()); } if (network.getSubnetIds() != null) { builder.withSubnetMetas(network.getSubnetIds().stream() .collect(Collectors.toMap(id -> id, id -> new CloudSubnet(id, id)))); } return builder .withNetworkCidr(network.getNetworkCidr()) .withNetworkCidrs(getNetworkCidrs(network)) .withPrivateSubnetCreation(getPrivateSubnetCreation(network)) .withServiceEndpointCreation(getServiceEndpointCreation(network)) .withOutboundInternetTraffic(getOutboundInternetTraffic(network)) .build(); }  NetworkDto convert(EnvironmentNetworkRequest network);  }