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);
}
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;
}
Aggregations