use of com.sequenceiq.environment.api.v1.credential.model.response.CredentialViewResponse 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.credential.model.response.CredentialViewResponse in project cloudbreak by hortonworks.
the class CredentialViewConverterTest method testConvertCredentialView.
@Test
void testConvertCredentialView() {
CredentialView credentialView = new CredentialView();
credentialView.setName(CRED_NAME);
credentialView.setCloudPlatform(CLOUD_PLATFORM);
credentialView.setCreator(CREATOR);
credentialView.setResourceCrn(CRN);
credentialView.setDescription(DESCRIPTION);
credentialView.setVerificationStatusText(VERIFICATION_STATUS_TEXT);
credentialView.setType(CredentialType.ENVIRONMENT);
credentialView.setGovCloud(true);
CredentialViewResponse result = underTest.convert(credentialView);
assertEquals(CRED_NAME, result.getName());
assertEquals(CLOUD_PLATFORM, result.getCloudPlatform());
assertEquals(CREATOR, result.getCreator());
assertEquals(CRN, result.getCrn());
assertEquals(DESCRIPTION, result.getDescription());
assertEquals(VERIFICATION_STATUS_TEXT, result.getVerificationStatusText());
assertEquals(CredentialType.ENVIRONMENT, result.getType());
assertTrue(result.getGovCloud());
}
use of com.sequenceiq.environment.api.v1.credential.model.response.CredentialViewResponse in project cloudbreak by hortonworks.
the class CredentialViewConverterTest method testConvertToCredentialViewResponse.
@Test
void testConvertToCredentialViewResponse() {
Credential credential = new Credential();
credential.setName(CRED_NAME);
credential.setCloudPlatform(CLOUD_PLATFORM);
credential.setCreator(CREATOR);
credential.setResourceCrn(CRN);
credential.setDescription(DESCRIPTION);
credential.setVerificationStatusText(VERIFICATION_STATUS_TEXT);
credential.setType(CredentialType.ENVIRONMENT);
credential.setGovCloud(true);
CredentialViewResponse result = underTest.convertResponse(credential);
assertEquals(CRED_NAME, result.getName());
assertEquals(CLOUD_PLATFORM, result.getCloudPlatform());
assertEquals(CREATOR, result.getCreator());
assertEquals(CRN, result.getCrn());
assertEquals(DESCRIPTION, result.getDescription());
assertEquals(VERIFICATION_STATUS_TEXT, result.getVerificationStatusText());
assertEquals(CredentialType.ENVIRONMENT, result.getType());
assertTrue(result.getGovCloud());
}
use of com.sequenceiq.environment.api.v1.credential.model.response.CredentialViewResponse in project cloudbreak by hortonworks.
the class CredentialViewConverter method convertResponse.
public CredentialViewResponse convertResponse(Credential credential) {
CredentialViewResponse response = new CredentialViewResponse();
response.setName(credential.getName());
response.setCloudPlatform(credential.getCloudPlatform());
response.setCreator(credential.getCreator());
response.setCrn(credential.getResourceCrn());
response.setDescription(credential.getDescription());
response.setVerificationStatusText(credential.getVerificationStatusText());
response.setType(credential.getType());
response.setGovCloud(credential.getGovCloud());
return response;
}
use of com.sequenceiq.environment.api.v1.credential.model.response.CredentialViewResponse 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