use of com.sequenceiq.environment.environment.dto.FreeIpaCreationDto in project cloudbreak by hortonworks.
the class EnvironmentDetailsToCDPFreeIPADetailsConverter method convert.
public UsageProto.CDPFreeIPADetails convert(EnvironmentDetails environmentDetails) {
UsageProto.CDPFreeIPADetails.Builder cdpFreeIPADetails = UsageProto.CDPFreeIPADetails.newBuilder();
cdpFreeIPADetails.setNodes(DEFAULT_INTEGER_VALUE);
if (environmentDetails != null) {
FreeIpaCreationDto freeIpaCreationDto = environmentDetails.getFreeIpaCreation();
if (freeIpaCreationDto != null) {
cdpFreeIPADetails.setNodes(freeIpaCreationDto.getInstanceCountByGroup());
cdpFreeIPADetails.setMultiAz(freeIpaCreationDto.isEnableMultiAz());
FreeIpaCreationAwsParametersDto aws = freeIpaCreationDto.getAws();
if (aws != null) {
FreeIpaCreationAwsSpotParametersDto spot = aws.getSpot();
if (spot != null && spot.getPercentage() != null) {
cdpFreeIPADetails.setSpot(spot.getPercentage() > 0);
}
}
}
}
UsageProto.CDPFreeIPADetails ret = cdpFreeIPADetails.build();
LOGGER.debug("Converted CDPFreeIPADetails: {}", ret);
return ret;
}
use of com.sequenceiq.environment.environment.dto.FreeIpaCreationDto 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.FreeIpaCreationDto in project cloudbreak by hortonworks.
the class FreeIpaConverterTest method testConvertWithInstanceType.
@Test
public void testConvertWithInstanceType() {
// GIVEN
AttachedFreeIpaRequest request = new AttachedFreeIpaRequest();
request.setCreate(true);
request.setInstanceType(INSTANCE_TYPE);
// WHEN
FreeIpaCreationDto result = underTest.convert(request, "id", CloudConstants.AWS);
// THEN
assertNotNull(result.getInstanceType());
assertEquals(INSTANCE_TYPE, result.getInstanceType());
}
use of com.sequenceiq.environment.environment.dto.FreeIpaCreationDto in project cloudbreak by hortonworks.
the class FreeIpaConverterTest method testConvertWithFreeIpaImageCatalogButWithoutImageId.
@Test
public void testConvertWithFreeIpaImageCatalogButWithoutImageId() {
// GIVEN
FreeIpaCreationDto request = FreeIpaCreationDto.builder().withImageCatalog(IMAGE_CATALOG).build();
// WHEN
FreeIpaResponse result = underTest.convert(request);
// THEN
assertNull(result.getImage());
}
use of com.sequenceiq.environment.environment.dto.FreeIpaCreationDto in project cloudbreak by hortonworks.
the class FreeIpaConverterTest method testConvertWithoutImage.
@Test
public void testConvertWithoutImage() {
// GIVEN
AttachedFreeIpaRequest request = new AttachedFreeIpaRequest();
request.setCreate(true);
request.setImage(null);
// WHEN
FreeIpaCreationDto result = underTest.convert(request, "id", CloudConstants.AWS);
// THEN
assertNull(result.getImageCatalog());
assertNull(result.getImageId());
}
Aggregations