### Question:
EnvironmentValidator { public void checkValidEnvironment(String stackName, DatabaseAvailabilityType externalDatabase, DetailedEnvironmentResponse environment) { LOGGER.debug("Checking environment validity for stack {}", stackName); if (CloudPlatform.AWS.name().equalsIgnoreCase(environment.getCloudPlatform())) { checkAwsEnvironment(stackName, externalDatabase, environment); } }  void checkValidEnvironment(String stackName, DatabaseAvailabilityType externalDatabase, DetailedEnvironmentResponse environment);  }### Answer:
@Test void checkValidEnvironmentAzure() { DetailedEnvironmentResponse environment = createEnvironment(CloudPlatform.AZURE.name(), Map.of()); underTest.checkValidEnvironment(STACKNAME, DatabaseAvailabilityType.HA, environment); }
@Test void checkValidEnvironmentAwsNonHA() { DetailedEnvironmentResponse environment = createEnvironment(CloudPlatform.AWS.name(), Map.of()); underTest.checkValidEnvironment(STACKNAME, DatabaseAvailabilityType.NON_HA, environment); }
@Test void checkValidEnvironmentAwsHANotEnoughSubnets() { Map<String, CloudSubnet> subnetMetas = Map.of("subnet1", new CloudSubnet()); DetailedEnvironmentResponse environment = createEnvironment(CloudPlatform.AWS.name(), subnetMetas); assertThatThrownBy(() -> underTest.checkValidEnvironment(STACKNAME, DatabaseAvailabilityType.HA, environment)) .isInstanceOf(BadRequestException.class) .hasMessageContaining("not enough subnets in the vpc"); }
@Test void checkValidEnvironmentAwsHANotEnoughAZs() { Map<String, CloudSubnet> subnetMetas = Map.of("subnet1", new CloudSubnet("id1", "name1", "az1", "cidr"), "subnet2", new CloudSubnet("id2", "name2", "az1", "cidr")); DetailedEnvironmentResponse environment = createEnvironment(CloudPlatform.AWS.name(), subnetMetas); assertThatThrownBy(() -> underTest.checkValidEnvironment(STACKNAME, DatabaseAvailabilityType.HA, environment)) .isInstanceOf(BadRequestException.class) .hasMessageContaining("vpc subnets must cover at least two different availability zones"); }
@Test void checkValidEnvironmentAwsHA() { Map<String, CloudSubnet> subnetMetas = Map.of("subnet1", new CloudSubnet("id1", "name1", "az1", "cidr"), "subnet2", new CloudSubnet("id2", "name2", "az2", "cidr")); DetailedEnvironmentResponse environment = createEnvironment(CloudPlatform.AWS.name(), subnetMetas); underTest.checkValidEnvironment(STACKNAME, DatabaseAvailabilityType.HA, environment); }