use of com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request in project cloudbreak by hortonworks.
the class DistroXV1RequestToStackV4RequestConverterTest method convertAvailabilityZoneComesFromEnv.
@Test
void convertAvailabilityZoneComesFromEnv() {
DistroXV1Request source = new DistroXV1Request();
source.setEnvironmentName("envname");
DistroXDatabaseRequest databaseRequest = new DistroXDatabaseRequest();
databaseRequest.setAvailabilityType(DistroXDatabaseAvailabilityType.HA);
source.setExternalDatabase(databaseRequest);
DetailedEnvironmentResponse env = createAwsEnvironment();
env.getNetwork().setSubnetMetas(Map.of("SubnetMeta", createCloudSubnet()));
when(environmentClientService.getByName(source.getEnvironmentName())).thenReturn(env);
when(networkConverter.convertToNetworkV4Request(any())).thenReturn(createAwsNetworkV4Request());
when(databaseRequestConverter.convert(any(DistroXDatabaseRequest.class))).thenReturn(createDatabaseRequest());
StackV4Request convert = underTest.convert(source);
assertThat(convert.getExternalDatabase()).isNotNull();
assertThat(convert.getExternalDatabase().getAvailabilityType()).isEqualTo(DatabaseAvailabilityType.HA);
}
use of com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request in project cloudbreak by hortonworks.
the class DistroXV1RequestToStackV4RequestConverterTest method convertStackRequest.
@Test
void convertStackRequest() {
when(databaseRequestConverter.convert(any(DatabaseRequest.class))).thenReturn(createDistroXDatabaseRequest());
StackV4Request source = new StackV4Request();
source.setName("stackname");
DatabaseRequest databaseRequest = new DatabaseRequest();
databaseRequest.setAvailabilityType(DatabaseAvailabilityType.HA);
source.setExternalDatabase(databaseRequest);
DistroXV1Request convert = underTest.convert(source);
assertThat(convert.getExternalDatabase()).isNotNull();
assertThat(convert.getExternalDatabase().getAvailabilityType()).isEqualTo(DistroXDatabaseAvailabilityType.HA);
}
use of com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request in project cloudbreak by hortonworks.
the class DistroXV1RequestToStackV4RequestConverterTest method testStackV4RequestToDistroXV1RequestWhenEnvironmentCrnIsNullThenNoCallHappensTowardsTheEnvironmentClientServiceAndNoEnvNameSetHappens.
@Test
void testStackV4RequestToDistroXV1RequestWhenEnvironmentCrnIsNullThenNoCallHappensTowardsTheEnvironmentClientServiceAndNoEnvNameSetHappens() {
StackV4Request source = new StackV4Request();
source.setName("SomeStack");
source.setEnvironmentCrn(null);
DistroXV1Request result = assertDoesNotThrow(() -> underTest.convert(source));
verify(environmentClientService, never()).getByCrn(any());
Assertions.assertNull(result.getEnvironmentName());
}
use of com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request in project cloudbreak by hortonworks.
the class DistroXV1RequestToStackV4RequestConverterTest method testStackV4RequestToDistroXV1RequestRegardlessOfTheStateOfTheEnvironment.
@ParameterizedTest
@EnumSource(EnvironmentStatus.class)
void testStackV4RequestToDistroXV1RequestRegardlessOfTheStateOfTheEnvironment(EnvironmentStatus status) {
StackV4Request source = new StackV4Request();
source.setName("SomeStack");
source.setEnvironmentCrn("SomeEnvCrn");
DetailedEnvironmentResponse env = createAwsEnvironment();
env.setCrn(source.getEnvironmentCrn());
env.setEnvironmentStatus(status);
when(environmentClientService.getByCrn(source.getEnvironmentCrn())).thenReturn(env);
DistroXV1Request result = assertDoesNotThrow(() -> underTest.convert(source));
verify(environmentClientService, times(1)).getByCrn(any());
verify(environmentClientService, times(1)).getByCrn(source.getEnvironmentCrn());
Assertions.assertEquals(env.getName(), result.getEnvironmentName());
}
use of com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request in project cloudbreak by hortonworks.
the class DistroXServiceTest method testIfDlIsNotRunning.
@Test
public void testIfDlIsNotRunning() {
String envName = "someAwesomeEnvironment";
DistroXV1Request request = new DistroXV1Request();
request.setEnvironmentName(envName);
DetailedEnvironmentResponse envResponse = new DetailedEnvironmentResponse();
envResponse.setEnvironmentStatus(AVAILABLE);
envResponse.setCrn("crn");
DescribeFreeIpaResponse freeipa = new DescribeFreeIpaResponse();
freeipa.setAvailabilityStatus(AvailabilityStatus.AVAILABLE);
freeipa.setStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.Status.AVAILABLE);
when(freeipaClientService.getByEnvironmentCrn("crn")).thenReturn(freeipa);
when(environmentClientService.getByName(envName)).thenReturn(envResponse);
when(platformAwareSdxConnector.listSdxCrns(any(), any())).thenReturn(Set.of(DATALAKE_CRN));
when(platformAwareSdxConnector.listSdxCrnsWithAvailability(any(), any(), any())).thenReturn(Set.of(Pair.of(DATALAKE_CRN, StatusCheckResult.NOT_AVAILABLE)));
assertThrows(BadRequestException.class, () -> underTest.post(request));
verify(platformAwareSdxConnector).listSdxCrns(any(), any());
verify(platformAwareSdxConnector).listSdxCrnsWithAvailability(any(), any(), any());
}
Aggregations