### Question:
TelemetryConverter { public Telemetry convert(TelemetryRequest request) { Telemetry telemetry = null; if (freeIpaTelemetryEnabled && request != null) { telemetry = new Telemetry(); telemetry.setLogging(createLoggingFromRequest(request.getLogging())); telemetry.setFeatures(createFeaturesFromRequest(request.getFeatures())); telemetry.setDatabusEndpoint(databusEndpoint); telemetry.setFluentAttributes(request.getFluentAttributes()); } return telemetry; } TelemetryConverter(TelemetryConfiguration configuration,
            @Value("${freeipa.telemetry.enabled:true}") boolean freeIpaTelemetryEnabled); Telemetry convert(TelemetryRequest request); TelemetryResponse convert(Telemetry telemetry);  }### Answer:
@Test public void testConvertFromRequest() { TelemetryRequest telemetryRequest = new TelemetryRequest(); LoggingRequest logging = new LoggingRequest(); logging.setS3(new S3CloudStorageV1Parameters()); FeaturesRequest featuresRequest = new FeaturesRequest(); featuresRequest.addClusterLogsCollection(false); telemetryRequest.setLogging(logging); telemetryRequest.setFeatures(featuresRequest); Telemetry result = underTest.convert(telemetryRequest); assertThat(result.getFeatures().getWorkloadAnalytics(), nullValue()); assertThat(result.getFeatures().getClusterLogsCollection().isEnabled(), is(false)); assertThat(result.getDatabusEndpoint(), is(DATABUS_ENDPOINT)); }
@Test public void testConvertToResponse() { Logging logging = new Logging(); S3CloudStorageV1Parameters s3Params = new S3CloudStorageV1Parameters(); s3Params.setInstanceProfile(INSTANCE_PROFILE_VALUE); logging.setS3(s3Params); Telemetry telemetry = new Telemetry(); telemetry.setLogging(logging); TelemetryResponse result = underTest.convert(telemetry); assertThat(result.getLogging().getS3().getInstanceProfile(), is(INSTANCE_PROFILE_VALUE)); }
@Test public void testConvertFromRequestForGCS() { TelemetryRequest telemetryRequest = new TelemetryRequest(); LoggingRequest logging = new LoggingRequest(); GcsCloudStorageV1Parameters gcsCloudStorageV1Parameters = new GcsCloudStorageV1Parameters(); gcsCloudStorageV1Parameters.setServiceAccountEmail(EMAIL); logging.setGcs(gcsCloudStorageV1Parameters); FeaturesRequest featuresRequest = new FeaturesRequest(); featuresRequest.addClusterLogsCollection(false); telemetryRequest.setLogging(logging); telemetryRequest.setFeatures(featuresRequest); Telemetry result = underTest.convert(telemetryRequest); assertThat(result.getFeatures().getWorkloadAnalytics(), nullValue()); assertThat(result.getFeatures().getClusterLogsCollection().isEnabled(), is(false)); assertThat(result.getDatabusEndpoint(), is(DATABUS_ENDPOINT)); assertThat(result.getLogging().getGcs(), notNullValue()); assertThat(result.getLogging().getGcs().getServiceAccountEmail(), is(EMAIL)); }
@Test public void testConvertToResponseForGcs() { Logging logging = new Logging(); GcsCloudStorageV1Parameters gcsCloudStorageV1Parameters = new GcsCloudStorageV1Parameters(); gcsCloudStorageV1Parameters.setServiceAccountEmail(EMAIL); logging.setGcs(gcsCloudStorageV1Parameters); Telemetry telemetry = new Telemetry(); telemetry.setLogging(logging); TelemetryResponse result = underTest.convert(telemetry); assertThat(result.getLogging().getGcs(), notNullValue()); assertThat(result.getLogging().getGcs().getServiceAccountEmail(), is(EMAIL)); }