Search in sources :

Example 1 with CredentialViewResponse

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);
}
Also used : CredentialViewResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialViewResponse) TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) CompactRegionResponse(com.sequenceiq.environment.api.v1.environment.model.response.CompactRegionResponse) ProxyViewResponse(com.sequenceiq.environment.api.v1.proxy.model.response.ProxyViewResponse) SimpleEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponse) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) FreeIpaResponse(com.sequenceiq.environment.api.v1.environment.model.response.FreeIpaResponse) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with CredentialViewResponse

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());
}
Also used : CredentialViewResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialViewResponse) CredentialView(com.sequenceiq.environment.credential.domain.CredentialView) Test(org.junit.jupiter.api.Test)

Example 3 with CredentialViewResponse

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());
}
Also used : CredentialViewResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialViewResponse) Credential(com.sequenceiq.environment.credential.domain.Credential) Test(org.junit.jupiter.api.Test)

Example 4 with CredentialViewResponse

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;
}
Also used : CredentialViewResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialViewResponse)

Example 5 with CredentialViewResponse

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);
}
Also used : CredentialViewResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialViewResponse) StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) SimpleEnvironmentResponses(com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponses) SimpleEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponse) NameOrCrn(com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn) Test(org.junit.jupiter.api.Test)

Aggregations

CredentialViewResponse (com.sequenceiq.environment.api.v1.credential.model.response.CredentialViewResponse)6 Test (org.junit.jupiter.api.Test)3 SimpleEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponse)2 NameOrCrn (com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn)1 StackViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response)1 TelemetryResponse (com.sequenceiq.common.api.telemetry.response.TelemetryResponse)1 CompactRegionResponse (com.sequenceiq.environment.api.v1.environment.model.response.CompactRegionResponse)1 EnvironmentNetworkResponse (com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse)1 FreeIpaResponse (com.sequenceiq.environment.api.v1.environment.model.response.FreeIpaResponse)1 SimpleEnvironmentResponses (com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponses)1 ProxyViewResponse (com.sequenceiq.environment.api.v1.proxy.model.response.ProxyViewResponse)1 Credential (com.sequenceiq.environment.credential.domain.Credential)1 CredentialView (com.sequenceiq.environment.credential.domain.CredentialView)1 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 EnumSource (org.junit.jupiter.params.provider.EnumSource)1