### Question:
EnvironmentNetworkProviderValidator { public ValidationResult validate(EnvironmentDto environmentDto) { NetworkDto network = environmentDto.getNetwork(); String cloudPlatform = environmentDto.getCloudPlatform(); ValidationResultBuilder resultBuilder = ValidationResult.builder(); validateNetworkHasTheSamePropertyFilledAsTheDesiredCloudPlatform(network, cloudPlatform, resultBuilder); validateNetwork(network, cloudPlatform, resultBuilder, environmentDto); validateSecurityGroup(environmentDto, cloudPlatform, resultBuilder); return resultBuilder.build(); } EnvironmentNetworkProviderValidator(
            Map<CloudPlatform, EnvironmentNetworkValidator> environmentNetworkValidatorsByCloudPlatform,
            Map<CloudPlatform, EnvironmentSecurityGroupValidator> environmentSecurityGroupValidatorsByCloudPlatform); ValidationResult validate(EnvironmentDto environmentDto);  }### Answer:
@Test void testIfCloudPlatformMatchesWithTheGivenNetworkInstanceThenItShouldBeFine() { NetworkDto network = NetworkDto.builder().withAws(new AwsParams()).build(); ValidationResult result = underTest.validate(getEnvDto(network)); assertFalse(result.hasError()); }
@Test void testIfCloudPlatformDoesNotMatchWithTheGivenNetworkParamInstanceThenErrorComes() { NetworkDto network = NetworkDto.builder().withAzure(new AzureParams()).build(); ValidationResult result = underTest.validate(getEnvDto(network)); assertTrue(result.hasError()); assertEquals(1, result.getErrors().size()); assertTrue(result.getErrors().get(0).contains("The related network parameter for the cloud platform \"" + CLOUD_PLATFORM.name() + "\" has not given!")); }
@Test void testIfNetworkParamsHasNotSpecifiedThenNoErrorComes() { ValidationResult result = underTest.validate(EnvironmentDto.builder().withCloudPlatform("AWS").build()); assertFalse(result.hasError()); }
@Test void testNetworkHasValidCidrShouldPass() { NetworkDto network = NetworkDto.builder().withNetworkCidr("10.128.0.0/16").build(); ValidationResult result = underTest.validate(getEnvDto(network)); assertFalse(result.hasError()); }