use of com.sequenceiq.common.api.telemetry.model.Features in project cloudbreak by hortonworks.
the class TelemetryApiConverterTest method testConvertWithMonitoringFeatureWithoutCdpSaas.
@Test
public void testConvertWithMonitoringFeatureWithoutCdpSaas() {
// GIVEN
TelemetryRequest telemetryRequest = new TelemetryRequest();
given(entitlementService.isCdpSaasEnabled(anyString())).willReturn(false);
FeaturesRequest featuresRequest = new FeaturesRequest();
featuresRequest.addMonitoring(true);
telemetryRequest.setFeatures(featuresRequest);
// WHEN
EnvironmentTelemetry result = underTest.convert(telemetryRequest, new Features(), ACCOUNT_ID);
// THEN
assertTrue(result.getFeatures().getMonitoring().isEnabled());
assertNull(result.getMonitoring().getRemoteWriteUrl());
}
use of com.sequenceiq.common.api.telemetry.model.Features in project cloudbreak by hortonworks.
the class TelemetryApiConverterTest method testConvertWithWAFeature.
@Test
public void testConvertWithWAFeature() {
// GIVEN
TelemetryRequest telemetryRequest = new TelemetryRequest();
FeaturesRequest fr = new FeaturesRequest();
fr.addWorkloadAnalytics(true);
telemetryRequest.setFeatures(fr);
// WHEN
EnvironmentTelemetry result = underTest.convert(telemetryRequest, new Features(), ACCOUNT_ID);
// THEN
assertTrue(result.getFeatures().getWorkloadAnalytics().isEnabled());
}
use of com.sequenceiq.common.api.telemetry.model.Features in project cloudbreak by hortonworks.
the class TelemetryApiConverterTest method testConvertWithDefaults.
@Test
public void testConvertWithDefaults() {
// GIVEN
TelemetryRequest telemetryRequest = new TelemetryRequest();
// WHEN
EnvironmentTelemetry result = underTest.convert(telemetryRequest, new Features(), ACCOUNT_ID);
// THEN
assertNull(result.getFeatures());
}
use of com.sequenceiq.common.api.telemetry.model.Features in project cloudbreak by hortonworks.
the class EnvironmentApiConverterTest method testInitCreationDto.
@ParameterizedTest
@EnumSource(value = CloudPlatform.class, names = { "AWS", "AZURE", "GCP" })
void testInitCreationDto(CloudPlatform cloudPlatform) {
EnvironmentRequest request = createEnvironmentRequest(cloudPlatform);
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(cloudPlatform.name());
when(freeIpaConverter.convert(request.getFreeIpa(), "test-aws", cloudPlatform.name())).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("test-aws", actual.getAccountId());
assertEquals(USER_CRN, actual.getCreator());
assertEquals(request.getName(), actual.getName());
assertEquals(request.getDescription(), actual.getDescription());
assertEquals(request.getCredentialName(), actual.getCredential().getCredentialName());
assertEquals(request, actual.getCredential());
assertEquals(freeIpaCreationDto, actual.getFreeIpaCreation());
assertLocation(request.getLocation(), actual.getLocation());
assertEquals(environmentTelemetry, actual.getTelemetry());
assertEquals(1, actual.getRegions().size());
assertAuthentication(request.getAuthentication(), actual.getAuthentication());
assertEquals(request.getAdminGroupName(), actual.getAdminGroupName());
assertEquals(request.getTags(), actual.getTags());
assertExperimentalFeatures(request, actual.getExperimentalFeatures());
assertParameters(request, actual.getParameters(), cloudPlatform);
assertEquals(request.getProxyConfigName(), actual.getProxyConfigName());
assertEquals(networkDto, actual.getNetwork());
assertSecurityAccess(request.getSecurityAccess(), actual.getSecurityAccess());
verify(credentialService).getCloudPlatformByCredential(anyString(), anyString(), any());
verify(freeIpaConverter).convert(request.getFreeIpa(), "test-aws", cloudPlatform.name());
verify(accountTelemetry).getFeatures();
verify(accountTelemetryService).getOrDefault(any());
verify(telemetryApiConverter).convert(eq(request.getTelemetry()), any(), anyString());
verify(tunnelConverter).convert(request.getTunnel());
verify(networkRequestToDtoConverter).convert(request.getNetwork());
}
use of com.sequenceiq.common.api.telemetry.model.Features in project cloudbreak by hortonworks.
the class EnvironmentApiConverterTest method testGcpResourceEncryptionParametersAndGcpRequest.
@Test
void testGcpResourceEncryptionParametersAndGcpRequest() {
EnvironmentRequest request = createEnvironmentRequest(GCP);
request.setGcp(GcpEnvironmentParameters.builder().withResourceEncryptionParameters(GcpResourceEncryptionParameters.builder().withEncryptionKey("dummy-encryption-key").build()).build());
FreeIpaCreationDto freeIpaCreationDto = mock(FreeIpaCreationDto.class);
EnvironmentTelemetry environmentTelemetry = mock(EnvironmentTelemetry.class);
EnvironmentBackup environmentBackup = mock(EnvironmentBackup.class);
AccountTelemetry accountTelemetry = mock(AccountTelemetry.class);
Features features = mock(Features.class);
NetworkDto networkDto = mock(NetworkDto.class);
when(credentialService.getCloudPlatformByCredential(anyString(), anyString(), any())).thenReturn(GCP.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(backupConverter.convert(eq(request.getBackup()))).thenReturn(environmentBackup);
when(tunnelConverter.convert(request.getTunnel())).thenReturn(request.getTunnel());
when(networkRequestToDtoConverter.convert(request.getNetwork())).thenReturn(networkDto);
EnvironmentCreationDto actual = testInitCreationDto(request);
assertEquals("dummy-encryption-key", actual.getParameters().getGcpParametersDto().getGcpResourceEncryptionParametersDto().getEncryptionKey());
}
Aggregations