Search in sources :

Example 6 with DistroXV1Request

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);
}
Also used : StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) DistroXDatabaseRequest(com.sequenceiq.distrox.api.v1.distrox.model.database.DistroXDatabaseRequest) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) DistroXV1Request(com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with DistroXV1Request

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);
}
Also used : StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) DatabaseRequest(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.database.DatabaseRequest) DistroXDatabaseRequest(com.sequenceiq.distrox.api.v1.distrox.model.database.DistroXDatabaseRequest) DistroXV1Request(com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 8 with DistroXV1Request

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());
}
Also used : StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) DistroXV1Request(com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 9 with DistroXV1Request

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());
}
Also used : StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) DistroXV1Request(com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 10 with DistroXV1Request

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());
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) DistroXV1Request(com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

DistroXV1Request (com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request)21 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)13 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)12 Test (org.junit.jupiter.api.Test)12 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)8 DescribeFreeIpaResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse)7 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)4 DistroXDatabaseRequest (com.sequenceiq.distrox.api.v1.distrox.model.database.DistroXDatabaseRequest)4 InstanceGroupV1Request (com.sequenceiq.distrox.api.v1.distrox.model.instancegroup.InstanceGroupV1Request)3 DisplayName (org.junit.jupiter.api.DisplayName)3 DatabaseRequest (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.database.DatabaseRequest)2 TagsV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.TagsV4Request)2 EnvironmentClientService (com.sequenceiq.cloudbreak.service.environment.EnvironmentClientService)2 NullUtil.getIfNotNull (com.sequenceiq.cloudbreak.util.NullUtil.getIfNotNull)2 DistroXClusterV1Request (com.sequenceiq.distrox.api.v1.distrox.model.cluster.DistroXClusterV1Request)2 Optional (java.util.Optional)2 Set (java.util.Set)2 Inject (javax.inject.Inject)2 DefaultClusterTemplateV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.clustertemplate.requests.DefaultClusterTemplateV4Request)1 ClusterTemplateViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.clustertemplate.responses.ClusterTemplateViewV4Response)1