use of com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry in project cloudbreak by hortonworks.
the class EnvironmentModificationServiceTest method testChangeTelemetryFeaturesByEnvironmentName.
@Test
public void testChangeTelemetryFeaturesByEnvironmentName() {
String accountId = "myAccountId";
String envName = "myEnvName";
EnvironmentFeatures featuresInput = new EnvironmentFeatures();
featuresInput.addClusterLogsCollection(true);
Environment environment = new Environment();
environment.setTelemetry(new EnvironmentTelemetry());
when(environmentService.findByNameAndAccountIdAndArchivedIsFalse(envName, accountId)).thenReturn(Optional.of(environment));
when(environmentService.save(environment)).thenReturn(environment);
when(environmentDtoConverter.environmentToDto(environment)).thenReturn(new EnvironmentDto());
environmentModificationServiceUnderTest.changeTelemetryFeaturesByEnvironmentName(accountId, envName, featuresInput);
verify(environmentService).save(any());
assertTrue(environment.getTelemetry().getFeatures().getClusterLogsCollection().isEnabled());
}
use of com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry in project cloudbreak by hortonworks.
the class EnvironmentApiConverterTest method testAzureSingleRgEnabledAndEmptyAzureRequest.
@Test
void testAzureSingleRgEnabledAndEmptyAzureRequest() {
EnvironmentRequest request = createEnvironmentRequest(AZURE);
request.setAzure(null);
FreeIpaCreationDto freeIpaCreationDto = mock(FreeIpaCreationDto.class);
EnvironmentTelemetry environmentTelemetry = mock(EnvironmentTelemetry.class);
AccountTelemetry accountTelemetry = mock(AccountTelemetry.class);
Features features = mock(Features.class);
NetworkDto networkDto = mock(NetworkDto.class);
when(credentialService.getCloudPlatformByCredential(anyString(), anyString(), any())).thenReturn(AZURE.name());
when(freeIpaConverter.convert(request.getFreeIpa(), "id", CloudConstants.AWS)).thenReturn(freeIpaCreationDto);
when(accountTelemetry.getFeatures()).thenReturn(features);
when(accountTelemetryService.getOrDefault(any())).thenReturn(accountTelemetry);
when(telemetryApiConverter.convert(eq(request.getTelemetry()), any(), anyString())).thenReturn(environmentTelemetry);
when(tunnelConverter.convert(request.getTunnel())).thenReturn(request.getTunnel());
when(networkRequestToDtoConverter.convert(request.getNetwork())).thenReturn(networkDto);
EnvironmentCreationDto actual = testInitCreationDto(request);
assertEquals(ResourceGroupUsagePattern.USE_MULTIPLE, actual.getParameters().getAzureParametersDto().getAzureResourceGroupDto().getResourceGroupUsagePattern());
}
use of com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry in project cloudbreak by hortonworks.
the class TelemetryApiConverterTest method testConvertWithDefaultMonitoringFeatureWithoutCdpSaas.
@Test
public void testConvertWithDefaultMonitoringFeatureWithoutCdpSaas() {
// GIVEN
TelemetryRequest telemetryRequest = new TelemetryRequest();
given(entitlementService.isCdpSaasEnabled(anyString())).willReturn(false);
// WHEN
EnvironmentTelemetry result = underTest.convert(telemetryRequest, new Features(), ACCOUNT_ID);
// THEN
assertNull(result.getFeatures());
assertNull(result.getMonitoring().getRemoteWriteUrl());
}
use of com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry in project cloudbreak by hortonworks.
the class TelemetryApiConverterTest method testConvertWithDisabledMonitoringFeatureWithCdpSaas.
@Test
public void testConvertWithDisabledMonitoringFeatureWithCdpSaas() {
// GIVEN
TelemetryRequest telemetryRequest = new TelemetryRequest();
given(entitlementService.isCdpSaasEnabled(anyString())).willReturn(true);
FeaturesRequest featuresRequest = new FeaturesRequest();
featuresRequest.addMonitoring(false);
telemetryRequest.setFeatures(featuresRequest);
// WHEN
EnvironmentTelemetry result = underTest.convert(telemetryRequest, new Features(), ACCOUNT_ID);
// THEN
assertFalse(result.getFeatures().getMonitoring().isEnabled());
assertNotNull(result.getMonitoring().getRemoteWriteUrl());
}
use of com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry in project cloudbreak by hortonworks.
the class TelemetryApiConverterTest method testConvertToResponse.
@Test
public void testConvertToResponse() {
// GIVEN
EnvironmentLogging logging = new EnvironmentLogging();
S3CloudStorageParameters s3Params = new S3CloudStorageParameters();
s3Params.setInstanceProfile(INSTANCE_PROFILE_VALUE);
logging.setS3(s3Params);
EnvironmentTelemetry telemetry = new EnvironmentTelemetry();
telemetry.setLogging(logging);
// WHEN
TelemetryResponse result = underTest.convert(telemetry);
// THEN
assertEquals(INSTANCE_PROFILE_VALUE, result.getLogging().getS3().getInstanceProfile());
assertNull(result.getWorkloadAnalytics());
}
Aggregations