use of com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentRequest in project cloudbreak by hortonworks.
the class EnvironmentResourceServiceTest method setup.
@BeforeEach
void setup() {
request = new EnvironmentRequest();
request.setCredentialName(ENVIRONMENT_NAME);
}
use of com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentRequest 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.api.v1.environment.model.request.EnvironmentRequest in project cloudbreak by hortonworks.
the class EnvironmentValidatorServiceTest method testValidateAwsEnvironmentRequestNoAwsParams.
@Test
void testValidateAwsEnvironmentRequestNoAwsParams() {
when(credentialService.getCloudPlatformByCredential(anyString(), anyString(), any())).thenReturn("AWS");
EnvironmentRequest request = new EnvironmentRequest();
request.setCredentialName("aws-credential");
ValidationResult result = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.validateAwsEnvironmentRequest(request));
assertTrue(result.hasError());
assertEquals("S3Guard Dynamo DB table name is not found in environment request.", result.getErrors().get(0));
}
use of com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentRequest in project cloudbreak by hortonworks.
the class EnvironmentValidatorServiceTest method testValidateAwsEnvironmentRequestNotAWS.
@Test
void testValidateAwsEnvironmentRequestNotAWS() {
when(credentialService.getCloudPlatformByCredential(anyString(), anyString(), any())).thenReturn("AZURE");
EnvironmentRequest request = new EnvironmentRequest();
request.setCredentialName("azure-credential");
ValidationResult result = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.validateAwsEnvironmentRequest(request));
assertTrue(result.hasError());
assertEquals("Environment request is not for cloud platform AWS.", result.getErrors().get(0));
}
use of com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentRequest in project cloudbreak by hortonworks.
the class EnvironmentValidatorServiceTest method testValidateAwsEnvironmentRequestNoDynamoTable.
@Test
void testValidateAwsEnvironmentRequestNoDynamoTable() {
when(credentialService.getCloudPlatformByCredential(anyString(), anyString(), any())).thenReturn("AWS");
EnvironmentRequest request = new EnvironmentRequest();
request.setCredentialName("aws-credential");
AwsEnvironmentParameters aws = new AwsEnvironmentParameters();
aws.setS3guard(new S3GuardRequestParameters());
request.setAws(aws);
ValidationResult result = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.validateAwsEnvironmentRequest(request));
assertTrue(result.hasError());
assertEquals("S3Guard Dynamo DB table name is not found in environment request.", result.getErrors().get(0));
}
Aggregations