### Question:
DiagnosticsCollectionValidator { public void validate(BaseDiagnosticsCollectionRequest request, Telemetry telemetry, String stackCrn) { validate(request.getDestination(), telemetry, stackCrn, false); }  void validate(BaseDiagnosticsCollectionRequest request, Telemetry telemetry, String stackCrn); void validate(BaseCmDiagnosticsCollectionRequest request, Telemetry telemetry, String stackCrn); void validate(DiagnosticsDestination destination, Telemetry telemetry, String stackCrn, Boolean cmBundle);  }### Answer:
@Test void testValidateWithCloudStorageWithEmptyTelemetry() { BaseDiagnosticsCollectionRequest request = new BaseDiagnosticsCollectionRequest(); request.setDestination(DiagnosticsDestination.CLOUD_STORAGE); Telemetry telemetry = new Telemetry(); BadRequestException thrown = assertThrows(BadRequestException.class, () -> underTest.validate(request, telemetry, "stackCrn")); assertTrue(thrown.getMessage().contains("Cloud storage logging is disabled for this cluster")); }
@Test void testValidateWithCloudStorageWithEmptyTelemetryLoggingSetting() { BaseDiagnosticsCollectionRequest request = new BaseDiagnosticsCollectionRequest(); request.setDestination(DiagnosticsDestination.CLOUD_STORAGE); Telemetry telemetry = new Telemetry(); telemetry.setLogging(new Logging()); BadRequestException thrown = assertThrows(BadRequestException.class, () -> underTest.validate(request, telemetry, "stackCrn")); assertTrue(thrown.getMessage().contains("S3 or ABFS cloud storage logging setting should be enabled for stack")); }
@Test void testValidateWithValidCloudStorage() { BaseDiagnosticsCollectionRequest request = new BaseDiagnosticsCollectionRequest(); request.setDestination(DiagnosticsDestination.CLOUD_STORAGE); Telemetry telemetry = new Telemetry(); Logging logging = new Logging(); logging.setS3(new S3CloudStorageV1Parameters()); telemetry.setLogging(logging); underTest.validate(request, telemetry, "stackCrn"); }
@Test void testValidateWithSupportDestination() { BaseDiagnosticsCollectionRequest request = new BaseDiagnosticsCollectionRequest(); request.setDestination(DiagnosticsDestination.SUPPORT); Telemetry telemetry = new Telemetry(); BadRequestException thrown = assertThrows(BadRequestException.class, () -> underTest.validate(request, telemetry, "stackCrn")); assertTrue(thrown.getMessage().contains("Destination SUPPORT is not supported yet.")); }
@Test void testValidateWithInvalidEngDestination() { BaseDiagnosticsCollectionRequest request = new BaseDiagnosticsCollectionRequest(); request.setDestination(DiagnosticsDestination.ENG); Telemetry telemetry = new Telemetry(); BadRequestException thrown = assertThrows(BadRequestException.class, () -> underTest.validate(request, telemetry, "stackCrn")); assertTrue(thrown.getMessage().contains("Cluster log collection is not enabled for this stack")); }
@Test void testValidateWithValidEngDestination() { BaseDiagnosticsCollectionRequest request = new BaseDiagnosticsCollectionRequest(); request.setDestination(DiagnosticsDestination.ENG); Telemetry telemetry = new Telemetry(); Features features = new Features(); FeatureSetting clusterLogsCollection = new FeatureSetting(); clusterLogsCollection.setEnabled(true); features.setClusterLogsCollection(clusterLogsCollection); telemetry.setFeatures(features); underTest.validate(request, telemetry, "stackCrn"); }