@Test void testValidateShouldBeSuccessWhenStackRegionIsRegionNameAndEnvironmentsRegionsAreRegionNames() { String westUs2RegionName = "westus2"; String westUs2RegionDisplayName = "West US 2"; Stack stack = getStack(); User user = getUser(); stack.setRegion(westUs2RegionName); DetailedEnvironmentResponse environment = getEnvironmentResponse(); CompactRegionResponse regions = new CompactRegionResponse(); regions.getNames().add(westUs2RegionName); regions.getNames().add("westus"); environment.setRegions(regions); when(connector.displayNameToRegion(any())).thenReturn(westUs2RegionName); when(connector.regionToDisplayName(any())).thenReturn(westUs2RegionDisplayName); when(sdxClientService.getByEnvironmentCrn(any())).thenReturn(Arrays.asList(new SdxClusterResponse())); ValidationResult.ValidationResultBuilder validationBuilder = ValidationResult.builder(); underTest.validate(stack, environment, user, true, validationBuilder); ValidationResult actualResult = validationBuilder.build(); assertFalse(actualResult.hasError()); }
public void validate(Stack stack, DetailedEnvironmentResponse environment, User user, boolean distroxRequest, ValidationResult.ValidationResultBuilder validationBuilder) { String regionName = cloudPlatformConnectors.getDefault(platform(stack.cloudPlatform())) .displayNameToRegion(stack.getRegion()); String displayName = cloudPlatformConnectors.getDefault(platform(stack.cloudPlatform())) .regionToDisplayName(stack.getRegion()); if (environment != null) { if (!CollectionUtils.isEmpty(environment.getRegions().getNames()) && environment.getRegions() .getNames() .stream() .noneMatch(region -> region.equals(regionName) || region.equals(displayName))) { validationBuilder.error(String.format("[%s] region is not enabled in [%s] environment. Enabled regions: [%s]", stack.getRegion(), environment.getName(), environment.getRegions().getNames().stream().sorted().collect(Collectors.joining(",")))); } } validateDatalakeConfig(stack, validationBuilder, user, distroxRequest); }
ClusterCreationEnvironmentValidator { public void validate(Stack stack, DetailedEnvironmentResponse environment, User user, boolean distroxRequest, ValidationResult.ValidationResultBuilder validationBuilder) { String regionName = cloudPlatformConnectors.getDefault(platform(stack.cloudPlatform())) .displayNameToRegion(stack.getRegion()); String displayName = cloudPlatformConnectors.getDefault(platform(stack.cloudPlatform())) .regionToDisplayName(stack.getRegion()); if (environment != null) { if (!CollectionUtils.isEmpty(environment.getRegions().getNames()) && environment.getRegions() .getNames() .stream() .noneMatch(region -> region.equals(regionName) || region.equals(displayName))) { validationBuilder.error(String.format("[%s] region is not enabled in [%s] environment. Enabled regions: [%s]", stack.getRegion(), environment.getName(), environment.getRegions().getNames().stream().sorted().collect(Collectors.joining(",")))); } } validateDatalakeConfig(stack, validationBuilder, user, distroxRequest); } }
ClusterCreationEnvironmentValidator { public void validate(Stack stack, DetailedEnvironmentResponse environment, User user, boolean distroxRequest, ValidationResult.ValidationResultBuilder validationBuilder) { String regionName = cloudPlatformConnectors.getDefault(platform(stack.cloudPlatform())) .displayNameToRegion(stack.getRegion()); String displayName = cloudPlatformConnectors.getDefault(platform(stack.cloudPlatform())) .regionToDisplayName(stack.getRegion()); if (environment != null) { if (!CollectionUtils.isEmpty(environment.getRegions().getNames()) && environment.getRegions() .getNames() .stream() .noneMatch(region -> region.equals(regionName) || region.equals(displayName))) { validationBuilder.error(String.format("[%s] region is not enabled in [%s] environment. Enabled regions: [%s]", stack.getRegion(), environment.getName(), environment.getRegions().getNames().stream().sorted().collect(Collectors.joining(",")))); } } validateDatalakeConfig(stack, validationBuilder, user, distroxRequest); }  }
ClusterCreationEnvironmentValidator { public void validate(Stack stack, DetailedEnvironmentResponse environment, User user, boolean distroxRequest, ValidationResult.ValidationResultBuilder validationBuilder) { String regionName = cloudPlatformConnectors.getDefault(platform(stack.cloudPlatform())) .displayNameToRegion(stack.getRegion()); String displayName = cloudPlatformConnectors.getDefault(platform(stack.cloudPlatform())) .regionToDisplayName(stack.getRegion()); if (environment != null) { if (!CollectionUtils.isEmpty(environment.getRegions().getNames()) && environment.getRegions() .getNames() .stream() .noneMatch(region -> region.equals(regionName) || region.equals(displayName))) { validationBuilder.error(String.format("[%s] region is not enabled in [%s] environment. Enabled regions: [%s]", stack.getRegion(), environment.getName(), environment.getRegions().getNames().stream().sorted().collect(Collectors.joining(",")))); } } validateDatalakeConfig(stack, validationBuilder, user, distroxRequest); }  void validate(Stack stack, DetailedEnvironmentResponse environment, User user, boolean distroxRequest,
        ValidationResult.ValidationResultBuilder validationBuilder); void validateRdsConfigNames(Set<String> rdsConfigNames, ValidationResultBuilder resultBuilder, Long workspaceId); void validateProxyConfig(String resourceCrn, ValidationResultBuilder resultBuilder); void validateAutoTls(
            ClusterV4Request clusterRequest,
            Stack stack,
            ValidationResultBuilder resultBuilder,
            String parentEnvironmentCloudPlatform); boolean hasFreeIpaKerberosConfig(Stack stack); }
ClusterCreationEnvironmentValidator { public void validate(Stack stack, DetailedEnvironmentResponse environment, User user, boolean distroxRequest, ValidationResult.ValidationResultBuilder validationBuilder) { String regionName = cloudPlatformConnectors.getDefault(platform(stack.cloudPlatform())) .displayNameToRegion(stack.getRegion()); String displayName = cloudPlatformConnectors.getDefault(platform(stack.cloudPlatform())) .regionToDisplayName(stack.getRegion()); if (environment != null) { if (!CollectionUtils.isEmpty(environment.getRegions().getNames()) && environment.getRegions() .getNames() .stream() .noneMatch(region -> region.equals(regionName) || region.equals(displayName))) { validationBuilder.error(String.format("[%s] region is not enabled in [%s] environment. Enabled regions: [%s]", stack.getRegion(), environment.getName(), environment.getRegions().getNames().stream().sorted().collect(Collectors.joining(",")))); } } validateDatalakeConfig(stack, validationBuilder, user, distroxRequest); }  void validate(Stack stack, DetailedEnvironmentResponse environment, User user, boolean distroxRequest,
        ValidationResult.ValidationResultBuilder validationBuilder); void validateRdsConfigNames(Set<String> rdsConfigNames, ValidationResultBuilder resultBuilder, Long workspaceId); void validateProxyConfig(String resourceCrn, ValidationResultBuilder resultBuilder); void validateAutoTls(
            ClusterV4Request clusterRequest,
            Stack stack,
            ValidationResultBuilder resultBuilder,
            String parentEnvironmentCloudPlatform); boolean hasFreeIpaKerberosConfig(Stack stack);  }