use of com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponse in project cloudbreak by hortonworks.
the class EnvironmentServiceDecorator method prepareEnvironments.
public void prepareEnvironments(Set<ClusterTemplateViewV4Response> clusterTemplateViewV4Responses) {
LOGGER.debug("Decorating with environment name the following cluster definition(s): {}", clusterTemplateViewV4Responses.stream().map(CompactViewV4Response::getName).collect(toSet()));
Collection<SimpleEnvironmentResponse> responses = environmentClientService.list().getResponses();
for (ClusterTemplateViewV4Response clusterTemplateViewV4Response : clusterTemplateViewV4Responses) {
Optional<SimpleEnvironmentResponse> first = responses.stream().filter(x -> x.getCrn().equals(clusterTemplateViewV4Response.getEnvironmentCrn())).findFirst();
first.ifPresentOrElse(simpleEnvironmentResponse -> clusterTemplateViewV4Response.setEnvironmentName(simpleEnvironmentResponse.getName()), () -> LOGGER.info("Unable to find environment name for cluster definition \"{}\"", clusterTemplateViewV4Response.getName()));
}
}
use of com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponse in project cloudbreak by hortonworks.
the class EnvironmentResponseConverterTest method testDtoToSimpleResponse.
@ParameterizedTest
@EnumSource(value = CloudPlatform.class, names = { "AWS", "AZURE" })
void testDtoToSimpleResponse(CloudPlatform cloudPlatform) {
EnvironmentDto environmentDto = createEnvironmentDto(cloudPlatform);
CredentialViewResponse credentialResponse = mock(CredentialViewResponse.class);
FreeIpaResponse freeIpaResponse = mock(FreeIpaResponse.class);
CompactRegionResponse compactRegionResponse = mock(CompactRegionResponse.class);
TelemetryResponse telemetryResponse = mock(TelemetryResponse.class);
ProxyViewResponse proxyResponse = mock(ProxyViewResponse.class);
EnvironmentNetworkResponse environmentNetworkResponse = mock(EnvironmentNetworkResponse.class);
when(credentialViewConverter.convertResponse(environmentDto.getCredential())).thenReturn(credentialResponse);
when(freeIpaConverter.convert(environmentDto.getFreeIpaCreation())).thenReturn(freeIpaResponse);
when(regionConverter.convertRegions(environmentDto.getRegions())).thenReturn(compactRegionResponse);
when(telemetryApiConverter.convert(environmentDto.getTelemetry())).thenReturn(telemetryResponse);
when(proxyConfigToProxyResponseConverter.convertToView(environmentDto.getProxyConfig())).thenReturn(proxyResponse);
when(networkDtoToResponseConverter.convert(environmentDto.getNetwork(), environmentDto.getExperimentalFeatures().getTunnel(), false)).thenReturn(environmentNetworkResponse);
SimpleEnvironmentResponse actual = underTest.dtoToSimpleResponse(environmentDto, true, true);
assertEquals(environmentDto.getResourceCrn(), actual.getCrn());
assertEquals(environmentDto.getName(), actual.getName());
assertEquals(environmentDto.getOriginalName(), actual.getOriginalName());
assertEquals(environmentDto.getDescription(), actual.getDescription());
assertEquals(environmentDto.getCloudPlatform(), actual.getCloudPlatform());
assertEquals(credentialResponse, actual.getCredential());
assertEquals(environmentDto.getStatus().getResponseStatus(), actual.getEnvironmentStatus());
assertEquals(environmentDto.getCreator(), actual.getCreator());
assertLocation(environmentDto.getLocation(), actual.getLocation());
assertTrue(actual.getCreateFreeIpa());
assertEquals(freeIpaResponse, actual.getFreeIpa());
assertEquals(environmentDto.getStatusReason(), actual.getStatusReason());
assertEquals(environmentDto.getCreated(), actual.getCreated());
assertEquals(environmentDto.getExperimentalFeatures().getTunnel(), actual.getTunnel());
assertEquals(environmentDto.getExperimentalFeatures().getCcmV2TlsType(), actual.getCcmV2TlsType());
assertEquals(environmentDto.getAdminGroupName(), actual.getAdminGroupName());
assertEquals(environmentDto.getTags().getUserDefinedTags(), actual.getTags().getUserDefined());
assertEquals(environmentDto.getTags().getDefaultTags(), actual.getTags().getDefaults());
assertEquals(telemetryResponse, actual.getTelemetry());
assertEquals(compactRegionResponse, actual.getRegions());
assertParameters(environmentDto, actual, cloudPlatform);
assertEquals(environmentDto.getParentEnvironmentName(), actual.getParentEnvironmentName());
assertEquals(proxyResponse, actual.getProxyConfig());
assertEquals(environmentNetworkResponse, actual.getNetwork());
verify(credentialViewConverter).convertResponse(environmentDto.getCredential());
verify(freeIpaConverter).convert(environmentDto.getFreeIpaCreation());
verify(regionConverter).convertRegions(environmentDto.getRegions());
verify(telemetryApiConverter).convert(environmentDto.getTelemetry());
verify(proxyConfigToProxyResponseConverter).convertToView(environmentDto.getProxyConfig());
verify(networkDtoToResponseConverter).convert(environmentDto.getNetwork(), environmentDto.getExperimentalFeatures().getTunnel(), false);
}
use of com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponse in project cloudbreak by hortonworks.
the class EnvironmentTestDto method delete.
@Override
public void delete(TestContext testContext, SimpleEnvironmentResponse entity, EnvironmentClient client) {
LOGGER.info("Delete resource with name: {}", entity.getName());
EnvironmentEndpoint credentialEndpoint = client.getDefaultClient().environmentV1Endpoint();
credentialEndpoint.deleteByName(entity.getName(), true, false);
setName(entity.getName());
testContext.await(this, Map.of("status", ARCHIVED));
}
use of com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponse in project cloudbreak by hortonworks.
the class EnvironmentDeleteAction method action.
@Override
public EnvironmentTestDto action(TestContext testContext, EnvironmentTestDto testDto, EnvironmentClient environmentClient) throws Exception {
SimpleEnvironmentResponse delete = environmentClient.getDefaultClient().environmentV1Endpoint().deleteByCrn(testDto.getResponse().getCrn(), true, false);
testDto.setResponseSimpleEnv(delete);
Log.whenJson("Environment delete response: ", delete);
return testDto;
}
use of com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponse in project cloudbreak by hortonworks.
the class EnvironmentServiceDecoratorTest method testPrepareEnvironmentsAndCredentialWithoutNameAndCrnWhenNameProvidedThenShouldCallGetEnvironmentList.
@Test
void testPrepareEnvironmentsAndCredentialWithoutNameAndCrnWhenNameProvidedThenShouldCallGetEnvironmentList() {
SimpleEnvironmentResponses simpleEnvironmentResponses = new SimpleEnvironmentResponses();
SimpleEnvironmentResponse simpleEnvironmentResponse = new SimpleEnvironmentResponse();
CredentialViewResponse credentialViewResponse = new CredentialViewResponse();
NameOrCrn nameOrCrn = mock(NameOrCrn.class);
StackViewV4Response stackViewV4Response = new StackViewV4Response();
stackViewV4Response.setEnvironmentCrn("env-crn");
Set<StackViewV4Response> stackViewResponses = Set.of(stackViewV4Response);
when(nameOrCrn.hasCrn()).thenReturn(false);
when(nameOrCrn.hasName()).thenReturn(false);
credentialViewResponse.setName("credential-name");
simpleEnvironmentResponse.setCredential(credentialViewResponse);
simpleEnvironmentResponse.setName("env-name");
simpleEnvironmentResponse.setCrn("env-crn");
simpleEnvironmentResponses.setResponses(Set.of(simpleEnvironmentResponse));
when(environmentClientService.list()).thenReturn(simpleEnvironmentResponses);
underTest.prepareEnvironmentsAndCredentialName(stackViewResponses, nameOrCrn);
verify(environmentClientService, times(1)).list();
assertEquals(stackViewResponses.iterator().next().getEnvironmentName(), "env-name");
assertEquals(stackViewResponses.iterator().next().getCredentialName(), "credential-name");
assertEquals(stackViewResponses.iterator().next().isGovCloud(), false);
}
Aggregations