Search in sources :

Example 1 with CompactRegionResponse

use of com.sequenceiq.environment.api.v1.environment.model.response.CompactRegionResponse in project cloudbreak by hortonworks.

the class EnvironmentResponseConverterTest method testDtoToDetailedResponse.

@ParameterizedTest
@EnumSource(value = CloudPlatform.class, names = { "AWS", "AZURE", "GCP" })
void testDtoToDetailedResponse(CloudPlatform cloudPlatform) {
    EnvironmentDto environment = createEnvironmentDto(cloudPlatform);
    CredentialResponse credentialResponse = mock(CredentialResponse.class);
    FreeIpaResponse freeIpaResponse = mock(FreeIpaResponse.class);
    CompactRegionResponse compactRegionResponse = mock(CompactRegionResponse.class);
    TelemetryResponse telemetryResponse = mock(TelemetryResponse.class);
    BackupResponse backupResponse = mock(BackupResponse.class);
    ProxyResponse proxyResponse = mock(ProxyResponse.class);
    EnvironmentNetworkResponse environmentNetworkResponse = mock(EnvironmentNetworkResponse.class);
    when(credentialConverter.convert(environment.getCredential())).thenReturn(credentialResponse);
    when(freeIpaConverter.convert(environment.getFreeIpaCreation())).thenReturn(freeIpaResponse);
    when(regionConverter.convertRegions(environment.getRegions())).thenReturn(compactRegionResponse);
    when(telemetryApiConverter.convert(environment.getTelemetry())).thenReturn(telemetryResponse);
    when(backupConverter.convert(environment.getBackup())).thenReturn(backupResponse);
    when(proxyConfigToProxyResponseConverter.convert((ProxyConfig) environment.getProxyConfig())).thenReturn(proxyResponse);
    when(networkDtoToResponseConverter.convert(environment.getNetwork(), environment.getExperimentalFeatures().getTunnel(), true)).thenReturn(environmentNetworkResponse);
    DetailedEnvironmentResponse actual = underTest.dtoToDetailedResponse(environment);
    assertEquals(environment.getResourceCrn(), actual.getCrn());
    assertEquals(environment.getName(), actual.getName());
    assertEquals(environment.getOriginalName(), actual.getOriginalName());
    assertEquals(environment.getDescription(), actual.getDescription());
    assertEquals(environment.getCloudPlatform(), actual.getCloudPlatform());
    assertEquals(credentialResponse, actual.getCredential());
    assertEquals(environment.getStatus().getResponseStatus(), actual.getEnvironmentStatus());
    assertLocation(environment.getLocation(), actual.getLocation());
    assertTrue(actual.getCreateFreeIpa());
    assertEquals(freeIpaResponse, actual.getFreeIpa());
    assertEquals(compactRegionResponse, actual.getRegions());
    assertEquals(environment.getCreator(), actual.getCreator());
    assertAuthentication(environment.getAuthentication(), actual.getAuthentication());
    assertEquals(environment.getStatusReason(), actual.getStatusReason());
    assertEquals(environment.getCreated(), actual.getCreated());
    assertEquals(environment.getTags().getUserDefinedTags(), actual.getTags().getUserDefined());
    assertEquals(environment.getTags().getDefaultTags(), actual.getTags().getDefaults());
    assertEquals(telemetryResponse, actual.getTelemetry());
    assertEquals(environment.getExperimentalFeatures().getTunnel(), actual.getTunnel());
    assertEquals(environment.getExperimentalFeatures().getIdBrokerMappingSource(), actual.getIdBrokerMappingSource());
    assertEquals(environment.getExperimentalFeatures().getCloudStorageValidation(), actual.getCloudStorageValidation());
    assertEquals(environment.getExperimentalFeatures().getCcmV2TlsType(), actual.getCcmV2TlsType());
    assertEquals(environment.getAdminGroupName(), actual.getAdminGroupName());
    assertParameters(environment, actual, cloudPlatform);
    assertEquals(environment.getParentEnvironmentCrn(), actual.getParentEnvironmentCrn());
    assertEquals(environment.getParentEnvironmentName(), actual.getParentEnvironmentName());
    assertEquals(environment.getParentEnvironmentCloudPlatform(), actual.getParentEnvironmentCloudPlatform());
    assertEquals(proxyResponse, actual.getProxyConfig());
    assertEquals(environmentNetworkResponse, actual.getNetwork());
    assertSecurityAccess(environment.getSecurityAccess(), actual.getSecurityAccess());
    verify(credentialConverter).convert(environment.getCredential());
    verify(freeIpaConverter).convert(environment.getFreeIpaCreation());
    verify(regionConverter).convertRegions(environment.getRegions());
    verify(telemetryApiConverter).convert(environment.getTelemetry());
    verify(proxyConfigToProxyResponseConverter).convert(environment.getProxyConfig());
    verify(networkDtoToResponseConverter).convert(environment.getNetwork(), environment.getExperimentalFeatures().getTunnel(), true);
}
Also used : TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) CompactRegionResponse(com.sequenceiq.environment.api.v1.environment.model.response.CompactRegionResponse) ProxyResponse(com.sequenceiq.environment.api.v1.proxy.model.response.ProxyResponse) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) CredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse) BackupResponse(com.sequenceiq.common.api.backup.response.BackupResponse) 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 CompactRegionResponse

use of com.sequenceiq.environment.api.v1.environment.model.response.CompactRegionResponse 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 3 with CompactRegionResponse

use of com.sequenceiq.environment.api.v1.environment.model.response.CompactRegionResponse in project cloudbreak by hortonworks.

the class ClusterCreationEnvironmentValidatorTest method testValidateShouldBeSuccessWhenStackRegionIsRegionDisplayNameAndEnvironmentsRegionsAreDisplayNames.

@Test
void testValidateShouldBeSuccessWhenStackRegionIsRegionDisplayNameAndEnvironmentsRegionsAreDisplayNames() {
    // GIVEN
    String westUs2RegionName = "westus2";
    String westUs2RegionDisplayName = "West US 2";
    Stack stack = getStack();
    stack.setRegion(westUs2RegionDisplayName);
    DetailedEnvironmentResponse environment = getEnvironmentResponse();
    CompactRegionResponse regions = new CompactRegionResponse();
    regions.getNames().add(westUs2RegionDisplayName);
    regions.getNames().add("West US");
    environment.setRegions(regions);
    when(connector.displayNameToRegion(any())).thenReturn(westUs2RegionName);
    when(connector.regionToDisplayName(any())).thenReturn(westUs2RegionDisplayName);
    when(sdxClientService.getByEnvironmentCrn(any())).thenReturn(Arrays.asList(new SdxClusterResponse()));
    ValidationResult.ValidationResultBuilder validationBuilder = ValidationResult.builder();
    // WHEN
    underTest.validate(stack, environment, true, validationBuilder);
    // THEN
    ValidationResult actualResult = validationBuilder.build();
    assertFalse(actualResult.hasError());
}
Also used : CompactRegionResponse(com.sequenceiq.environment.api.v1.environment.model.response.CompactRegionResponse) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with CompactRegionResponse

use of com.sequenceiq.environment.api.v1.environment.model.response.CompactRegionResponse in project cloudbreak by hortonworks.

the class ClusterCreationEnvironmentValidatorTest method testValidateShouldBeSuccessWhenStackRegionIsRegionNameAndEnvironmentsRegionsAreRegionNames.

@Test
void testValidateShouldBeSuccessWhenStackRegionIsRegionNameAndEnvironmentsRegionsAreRegionNames() {
    // GIVEN
    String westUs2RegionName = "westus2";
    String westUs2RegionDisplayName = "West US 2";
    Stack stack = getStack();
    stack.setRegion(westUs2RegionName);
    DetailedEnvironmentResponse environment = getEnvironmentResponse();
    CompactRegionResponse regions = new CompactRegionResponse();
    regions.getNames().add(westUs2RegionName);
    regions.getNames().add("westus");
    environment.setRegions(regions);
    when(connector.displayNameToRegion(any())).thenReturn(westUs2RegionName);
    when(connector.regionToDisplayName(any())).thenReturn(westUs2RegionDisplayName);
    when(sdxClientService.getByEnvironmentCrn(any())).thenReturn(Arrays.asList(new SdxClusterResponse()));
    ValidationResult.ValidationResultBuilder validationBuilder = ValidationResult.builder();
    // WHEN
    underTest.validate(stack, environment, true, validationBuilder);
    // THEN
    ValidationResult actualResult = validationBuilder.build();
    assertFalse(actualResult.hasError());
}
Also used : CompactRegionResponse(com.sequenceiq.environment.api.v1.environment.model.response.CompactRegionResponse) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with CompactRegionResponse

use of com.sequenceiq.environment.api.v1.environment.model.response.CompactRegionResponse in project cloudbreak by hortonworks.

the class ProvisionerServiceTest method getEnvironmentResponse.

private DetailedEnvironmentResponse getEnvironmentResponse() {
    DetailedEnvironmentResponse detailedEnvironmentResponse = new DetailedEnvironmentResponse();
    detailedEnvironmentResponse.setName("env");
    detailedEnvironmentResponse.setEnvironmentStatus(EnvironmentStatus.AVAILABLE);
    CompactRegionResponse compactRegionResponse = new CompactRegionResponse();
    compactRegionResponse.setNames(Lists.newArrayList("eu-west-1"));
    compactRegionResponse.setDisplayNames(Map.of("eu-west-1", "ireland"));
    detailedEnvironmentResponse.setRegions(compactRegionResponse);
    detailedEnvironmentResponse.setCrn(CrnTestUtil.getEnvironmentCrnBuilder().setResource(UUID.randomUUID().toString()).setAccountId(UUID.randomUUID().toString()).build().toString());
    EnvironmentNetworkResponse network = new EnvironmentNetworkResponse();
    network.setCrn(CrnTestUtil.getNetworkCrnBuilder().setResource(UUID.randomUUID().toString()).setAccountId(UUID.randomUUID().toString()).build().toString());
    EnvironmentNetworkAwsParams environmentNetworkAwsParams = new EnvironmentNetworkAwsParams();
    environmentNetworkAwsParams.setVpcId("vpc");
    network.setAws(environmentNetworkAwsParams);
    network.setSubnetIds(Sets.newHashSet("subnet"));
    CloudSubnet cloudSubnet = new CloudSubnet();
    cloudSubnet.setId("subnet");
    cloudSubnet.setName("subnet");
    cloudSubnet.setAvailabilityZone("eu-west-1a");
    Map<String, CloudSubnet> cloudSubnetMap = Map.of("subnet", cloudSubnet);
    network.setSubnetMetas(cloudSubnetMap);
    detailedEnvironmentResponse.setNetwork(network);
    EnvironmentAuthenticationResponse authentication = new EnvironmentAuthenticationResponse();
    authentication.setPublicKey("ssh-public-key");
    detailedEnvironmentResponse.setAuthentication(authentication);
    return detailedEnvironmentResponse;
}
Also used : CompactRegionResponse(com.sequenceiq.environment.api.v1.environment.model.response.CompactRegionResponse) EnvironmentNetworkAwsParams(com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkAwsParams) EnvironmentAuthenticationResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentAuthenticationResponse) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)

Aggregations

CompactRegionResponse (com.sequenceiq.environment.api.v1.environment.model.response.CompactRegionResponse)12 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)9 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)6 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)5 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)4 EnvironmentNetworkResponse (com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse)4 SdxClusterResponse (com.sequenceiq.sdx.api.model.SdxClusterResponse)4 Test (org.junit.jupiter.api.Test)4 CredentialResponse (com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse)3 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)2 TelemetryResponse (com.sequenceiq.common.api.telemetry.response.TelemetryResponse)2 FreeIpaResponse (com.sequenceiq.environment.api.v1.environment.model.response.FreeIpaResponse)2 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)2 EnumSource (org.junit.jupiter.params.provider.EnumSource)2 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)1 ExtendedCloudCredential (com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential)1 Platform (com.sequenceiq.cloudbreak.cloud.model.Platform)1 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)1 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)1