use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request 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.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request 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.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request 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.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request 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.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.
the class StackOperations method post.
public StackV4Response post(Long workspaceId, CloudbreakUser cloudbreakUser, @Valid StackV4Request request, boolean distroxRequest) {
LOGGER.info("Post for Stack in workspace {}.", workspaceId);
User user = userService.getOrCreate(cloudbreakUser);
LOGGER.info("Cloudbreak user for the requested stack is {}.", cloudbreakUser);
Workspace workspace = workspaceService.get(workspaceId, user);
StackV4Response stackV4Response = stackCommonService.createInWorkspace(request, user, workspace, distroxRequest);
LOGGER.info("Adding environment name and credential to the response.");
environmentServiceDecorator.prepareEnvironmentAndCredentialName(stackV4Response);
LOGGER.info("Adding SDX CRN and name to the response.");
sdxServiceDecorator.prepareSdxAttributes(stackV4Response);
return stackV4Response;
}
Aggregations