### Question:
TelemetryApiConverter { public EnvironmentTelemetry convert(TelemetryRequest request, Features accountFeatures) { EnvironmentTelemetry telemetry = null; if (request != null) { telemetry = new EnvironmentTelemetry(); telemetry.setLogging(createLoggingFromRequest(request.getLogging())); telemetry.setWorkloadAnalytics(createWorkloadAnalyticsFromRequest(request.getWorkloadAnalytics())); telemetry.setFeatures(createEnvironmentFeaturesFromRequest(request.getFeatures(), accountFeatures)); telemetry.setFluentAttributes(new HashMap<>(request.getFluentAttributes())); } return telemetry; } TelemetryApiConverter(TelemetryConfiguration configuration); EnvironmentTelemetry convert(TelemetryRequest request, Features accountFeatures); TelemetryResponse convert(EnvironmentTelemetry telemetry); TelemetryRequest convertToRequest(EnvironmentTelemetry telemetry);  }### Answer:
@Test public void testConvert() { TelemetryRequest telemetryRequest = new TelemetryRequest(); LoggingRequest loggingRequest = new LoggingRequest(); S3CloudStorageV1Parameters s3Params = new S3CloudStorageV1Parameters(); s3Params.setInstanceProfile(INSTANCE_PROFILE_VALUE); loggingRequest.setS3(s3Params); telemetryRequest.setLogging(loggingRequest); telemetryRequest.setWorkloadAnalytics(new WorkloadAnalyticsRequest()); FeaturesRequest fr = new FeaturesRequest(); fr.addClusterLogsCollection(true); fr.addWorkloadAnalytics(true); fr.addMonitoring(true); telemetryRequest.setFeatures(fr); EnvironmentTelemetry result = underTest.convert(telemetryRequest, new Features()); assertEquals(INSTANCE_PROFILE_VALUE, result.getLogging().getS3().getInstanceProfile()); assertTrue(result.getFeatures().getClusterLogsCollection().isEnabled()); assertTrue(result.getFeatures().getWorkloadAnalytics().isEnabled()); assertTrue(result.getFeatures().getUseSharedAltusCredential().isEnabled()); assertTrue(result.getFeatures().getMonitoring().isEnabled()); }
@Test public void testConvertWithDefaults() { TelemetryRequest telemetryRequest = new TelemetryRequest(); EnvironmentTelemetry result = underTest.convert(telemetryRequest, new Features()); assertNull(result.getFeatures()); }
@Test public void testConvertWithDefaultFeatures() { TelemetryRequest telemetryRequest = new TelemetryRequest(); FeaturesRequest fr = new FeaturesRequest(); telemetryRequest.setFeatures(fr); EnvironmentTelemetry result = underTest.convert(telemetryRequest, new Features()); assertNull(result.getFeatures().getWorkloadAnalytics()); }
@Test public void testConvertWithWAFeature() { TelemetryRequest telemetryRequest = new TelemetryRequest(); FeaturesRequest fr = new FeaturesRequest(); fr.addWorkloadAnalytics(true); telemetryRequest.setFeatures(fr); EnvironmentTelemetry result = underTest.convert(telemetryRequest, new Features()); assertTrue(result.getFeatures().getWorkloadAnalytics().isEnabled()); }
@Test public void testConvertWithWADisabled() { TelemetryRequest telemetryRequest = new TelemetryRequest(); FeaturesRequest fr = new FeaturesRequest(); fr.addWorkloadAnalytics(false); telemetryRequest.setFeatures(fr); EnvironmentTelemetry result = underTest.convert(telemetryRequest, new Features()); assertFalse(result.getFeatures().getWorkloadAnalytics().isEnabled()); }
@Test public void testConvertToResponse() { EnvironmentLogging logging = new EnvironmentLogging(); S3CloudStorageParameters s3Params = new S3CloudStorageParameters(); s3Params.setInstanceProfile(INSTANCE_PROFILE_VALUE); logging.setS3(s3Params); EnvironmentTelemetry telemetry = new EnvironmentTelemetry(); telemetry.setLogging(logging); TelemetryResponse result = underTest.convert(telemetry); assertEquals(INSTANCE_PROFILE_VALUE, result.getLogging().getS3().getInstanceProfile()); assertNull(result.getWorkloadAnalytics()); }