### Question:
NetworkV1ToNetworkV4Converter { public NetworkV4Request convertToNetworkV4Request(Pair<NetworkV1Request, DetailedEnvironmentResponse> network) { EnvironmentNetworkResponse value = network.getValue().getNetwork(); NetworkV1Request key = network.getKey(); if (key == null) { key = new NetworkV1Request(); } NetworkV4Request request = new NetworkV4Request(); switch (network.getValue().getCloudPlatform()) { case "AWS": request.setAws(getAwsNetworkParameters(Optional.ofNullable(key.getAws()), value)); break; case "AZURE": request.setAzure(getAzureNetworkParameters(Optional.ofNullable(key.getAzure()), value)); break; case "MOCK": request.setMock(getMockNetworkParameters(Optional.ofNullable(key.getMock()), value)); break; case "GCP": request.setGcp(getGcpNetworkParameters(Optional.ofNullable(key.getGcp()), value)); break; default: } return request; }  NetworkV4Request convertToNetworkV4Request(Pair<NetworkV1Request, DetailedEnvironmentResponse> network); NetworkV1Request convertToNetworkV1Request(NetworkV4Request network);  }### Answer:
@Test public void testConvertToStackRequestWhenAwsPresentedWithSubnet() { NetworkV1Request networkV1Request = awsNetworkV1Request(); DetailedEnvironmentResponse environmentNetworkResponse = awsEnvironmentNetwork(); NetworkV4Request networkV4Request = underTest .convertToNetworkV4Request(new ImmutablePair<>(networkV1Request, environmentNetworkResponse)); Assert.assertEquals(networkV4Request.createAws().getVpcId(), VPC_ID); Assert.assertEquals(networkV4Request.createAws().getSubnetId(), SUBNET_ID); }
@Test public void testConvertToStackRequestWhenAwsPresentedWithoutSubnet() { NetworkV1Request networkV1Request = awsEmptyNetworkV1Request(); DetailedEnvironmentResponse environmentNetworkResponse = awsEnvironmentNetwork(); NetworkV4Request networkV4Request = underTest .convertToNetworkV4Request(new ImmutablePair<>(networkV1Request, environmentNetworkResponse)); Assert.assertEquals(networkV4Request.createAws().getVpcId(), VPC_ID); Assert.assertTrue(SUBNET_IDS.contains(networkV4Request.createAws().getSubnetId())); }
@Test public void testConvertToStackRequestWhenAzurePresentedWithSubnet() { NetworkV1Request networkV1Request = azureNetworkV1Request(); DetailedEnvironmentResponse environmentNetworkResponse = azureEnvironmentNetwork(); NetworkV4Request networkV4Request = underTest .convertToNetworkV4Request(new ImmutablePair<>(networkV1Request, environmentNetworkResponse)); Assert.assertEquals(networkV4Request.createAzure().getNetworkId(), VPC_ID); Assert.assertEquals(networkV4Request.createAzure().getResourceGroupName(), GROUP_NAME); Assert.assertEquals(networkV4Request.createAzure().getSubnetId(), SUBNET_ID); }
@Test public void testConvertToStackRequestWhenAzurePresentedWithoutSubnet() { NetworkV1Request networkV1Request = azureEmptyNetworkV1Request(); DetailedEnvironmentResponse environmentNetworkResponse = azureEnvironmentNetwork(); NetworkV4Request networkV4Request = underTest .convertToNetworkV4Request(new ImmutablePair<>(networkV1Request, environmentNetworkResponse)); Assert.assertEquals(networkV4Request.createAzure().getNetworkId(), VPC_ID); Assert.assertEquals(networkV4Request.createAzure().getResourceGroupName(), GROUP_NAME); Assert.assertTrue(SUBNET_IDS.contains(networkV4Request.createAzure().getSubnetId())); }
@Test public void testConvertToStackRequestWhenYarnPresented() { NetworkV1Request networkV1Request = yarnNetworkV1Request(); DetailedEnvironmentResponse environmentNetworkResponse = yarnEnvironmentNetwork(); NetworkV4Request networkV4Request = underTest .convertToNetworkV4Request(new ImmutablePair<>(networkV1Request, environmentNetworkResponse)); Assert.assertTrue(networkV4Request.createYarn().asMap().size() == 1); }