### Question:
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);  }### Answer:
@Test public void validateTelemetryLoggingStorageLocationNoTelemetry() { when(environment.getTelemetry()).thenReturn(null); ValidationResult result = underTest.validateTelemetryLoggingStorageLocation(environment); assertFalse(result.hasError()); }
@Test public void validateTelemetryLoggingStorageLocationNoLogging() { when(environment.getTelemetry()).thenReturn(telemetry); when(telemetry.getLogging()).thenReturn(null); ValidationResult result = underTest.validateTelemetryLoggingStorageLocation(environment); assertFalse(result.hasError()); }
@Test public void validateTelemetryLoggingStorageLocationNoStoragerLocation() { when(environment.getTelemetry()).thenReturn(telemetry); when(telemetry.getLogging()).thenReturn(logging); when(logging.getS3()).thenReturn(new S3CloudStorageParameters()); when(logging.getStorageLocation()).thenReturn(null); ValidationResult result = underTest.validateTelemetryLoggingStorageLocation(environment); assertFalse(result.hasError()); }
@Test public void validateTelemetryLoggingStorageLocationValidatorPasses() { when(environment.getTelemetry()).thenReturn(telemetry); when(telemetry.getLogging()).thenReturn(logging); when(logging.getS3()).thenReturn(new S3CloudStorageParameters()); when(logging.getStorageLocation()).thenReturn(REGION_1); ValidationResult result = underTest.validateTelemetryLoggingStorageLocation(environment); assertFalse(result.hasError()); }