Search in sources :

Example 21 with DistroXV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request in project cloudbreak by hortonworks.

the class DistroXServiceTest method testWhenEnvExistsAndItIsAvailable.

@Test
@DisplayName("When the environment that has the given name is exist and also in the state AVAILABLE then no exception should come")
void testWhenEnvExistsAndItIsAvailable() throws IllegalAccessException {
    String envName = "someAwesomeEnvironment";
    DistroXV1Request r = new DistroXV1Request();
    r.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);
    StackV4Request converted = new StackV4Request();
    CloudbreakUser cloudbreakUser = mock(CloudbreakUser.class);
    when(stackRequestConverter.convert(r)).thenReturn(converted);
    when(platformAwareSdxConnector.listSdxCrns(any(), any())).thenReturn(Set.of(DATALAKE_CRN));
    when(restRequestThreadLocalService.getCloudbreakUser()).thenReturn(cloudbreakUser);
    underTest.post(r);
    verify(environmentClientService, calledOnce()).getByName(any());
    verify(environmentClientService, calledOnce()).getByName(envName);
    verify(stackOperations, calledOnce()).post(any(), any(), any(), anyBoolean());
    verify(stackOperations, calledOnce()).post(eq(USER_ID), eq(cloudbreakUser), eq(converted), eq(true));
    verify(workspaceService, calledOnce()).getForCurrentUser();
    verify(stackRequestConverter, calledOnce()).convert(any(DistroXV1Request.class));
    verify(stackRequestConverter, calledOnce()).convert(r);
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) CloudbreakUser(com.sequenceiq.cloudbreak.common.user.CloudbreakUser) DistroXV1Request(com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 22 with DistroXV1Request

use of com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request in project cloudbreak by hortonworks.

the class DistroXClusterToClusterConverter method convert.

public ClusterV4Request convert(DistroXV1Request request, DetailedEnvironmentResponse environment) {
    DistroXClusterV1Request source = request.getCluster();
    ClusterV4Request response = new ClusterV4Request();
    if (isEmpty(source.getExposedServices())) {
        source.setExposedServices(List.of("ALL"));
    }
    response.setGateway(gatewayConverter.convert(source.getExposedServices()));
    response.setName(null);
    response.setDatabases(source.getDatabases());
    response.setBlueprintName(source.getBlueprintName());
    response.setCustomConfigurationsName(source.getCustomConfigurationsName());
    response.setUserName(source.getUserName());
    response.setPassword(source.getPassword());
    response.setProxyConfigCrn(getIfNotNull(source.getProxy(), proxy -> getProxyCrnByName(ThreadBasedUserCrnProvider.getAccountId(), proxy)));
    response.setCm(getIfNotNull(source.getCm(), cmConverter::convert));
    response.setCloudStorage(cloudStorageDecorator.decorate(source.getBlueprintName(), request.getName(), source.getCloudStorage(), environment));
    response.setValidateBlueprint(source.getValidateBlueprint());
    response.setCustomContainer(null);
    response.setCustomQueue(null);
    return response;
}
Also used : List(java.util.List) Component(org.springframework.stereotype.Component) ThreadBasedUserCrnProvider(com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider) DistroXClusterV1Request(com.sequenceiq.distrox.api.v1.distrox.model.cluster.DistroXClusterV1Request) NullUtil.getIfNotNull(com.sequenceiq.cloudbreak.util.NullUtil.getIfNotNull) ProxyEndpoint(com.sequenceiq.environment.api.v1.proxy.endpoint.ProxyEndpoint) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) CollectionUtils.isEmpty(org.apache.commons.collections4.CollectionUtils.isEmpty) RegionAwareInternalCrnGeneratorFactory(com.sequenceiq.cloudbreak.auth.crn.RegionAwareInternalCrnGeneratorFactory) DistroXV1Request(com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request) ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) DistroXClusterV1Request(com.sequenceiq.distrox.api.v1.distrox.model.cluster.DistroXClusterV1Request)

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