@Test public void validateTelemetryLoggingStorageLocationNoTelemetry() { when(environment.getTelemetry()).thenReturn(null); ValidationResult result = underTest.validateTelemetryLoggingStorageLocation(environment); assertFalse(result.hasError()); }
public ValidationResult validateTelemetryLoggingStorageLocation(Environment environment) { ValidationResultBuilder resultBuilder = new ValidationResultBuilder(); Optional.ofNullable(environment.getTelemetry()) .map(EnvironmentTelemetry::getLogging) .filter(logging -> isCloudStorageEnabled(logging) && logging.getCloudwatch() == null) .map(EnvironmentLogging::getStorageLocation) .ifPresent(location -> cloudStorageLocationValidator.validate(location, environment, resultBuilder)); return resultBuilder.build(); }
EnvironmentLogStorageLocationValidator { public ValidationResult validateTelemetryLoggingStorageLocation(Environment environment) { ValidationResultBuilder resultBuilder = new ValidationResultBuilder(); Optional.ofNullable(environment.getTelemetry()) .map(EnvironmentTelemetry::getLogging) .filter(logging -> isCloudStorageEnabled(logging) && logging.getCloudwatch() == null) .map(EnvironmentLogging::getStorageLocation) .ifPresent(location -> cloudStorageLocationValidator.validate(location, environment, resultBuilder)); return resultBuilder.build(); } }
EnvironmentLogStorageLocationValidator { public ValidationResult validateTelemetryLoggingStorageLocation(Environment environment) { ValidationResultBuilder resultBuilder = new ValidationResultBuilder(); Optional.ofNullable(environment.getTelemetry()) .map(EnvironmentTelemetry::getLogging) .filter(logging -> isCloudStorageEnabled(logging) && logging.getCloudwatch() == null) .map(EnvironmentLogging::getStorageLocation) .ifPresent(location -> cloudStorageLocationValidator.validate(location, environment, resultBuilder)); return resultBuilder.build(); } EnvironmentLogStorageLocationValidator(CloudStorageLocationValidator cloudStorageLocationValidator); }
EnvironmentLogStorageLocationValidator { public ValidationResult validateTelemetryLoggingStorageLocation(Environment environment) { ValidationResultBuilder resultBuilder = new ValidationResultBuilder(); Optional.ofNullable(environment.getTelemetry()) .map(EnvironmentTelemetry::getLogging) .filter(logging -> isCloudStorageEnabled(logging) && logging.getCloudwatch() == null) .map(EnvironmentLogging::getStorageLocation) .ifPresent(location -> cloudStorageLocationValidator.validate(location, environment, resultBuilder)); return resultBuilder.build(); } EnvironmentLogStorageLocationValidator(CloudStorageLocationValidator cloudStorageLocationValidator); ValidationResult validateTelemetryLoggingStorageLocation(Environment environment); }
EnvironmentLogStorageLocationValidator { public ValidationResult validateTelemetryLoggingStorageLocation(Environment environment) { ValidationResultBuilder resultBuilder = new ValidationResultBuilder(); Optional.ofNullable(environment.getTelemetry()) .map(EnvironmentTelemetry::getLogging) .filter(logging -> isCloudStorageEnabled(logging) && logging.getCloudwatch() == null) .map(EnvironmentLogging::getStorageLocation) .ifPresent(location -> cloudStorageLocationValidator.validate(location, environment, resultBuilder)); return resultBuilder.build(); } EnvironmentLogStorageLocationValidator(CloudStorageLocationValidator cloudStorageLocationValidator); ValidationResult validateTelemetryLoggingStorageLocation(Environment environment);  }