Search in sources :

Example 11 with CompactRegionResponse

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

the class StackDecoratorTest method setUp.

@Before
public void setUp() {
    String credentialName = "credentialName";
    MockitoAnnotations.initMocks(this);
    subject = new Stack();
    subject.setEnvironmentCrn("envCrn");
    Set<InstanceGroup> instanceGroups = createInstanceGroups(GATEWAY);
    subject.setInstanceGroups(instanceGroups);
    Cluster cluster = getCluster(instanceGroups);
    subject.setCluster(cluster);
    subject.setCloudPlatform("AZURE");
    subject.setParameters(new HashMap<>());
    when(cloudParameterCache.getPlatformParameters()).thenReturn(platformParametersMap);
    when(platformParametersMap.get(any(Platform.class))).thenReturn(pps);
    when(pps.specialParameters()).thenReturn(specialParameters);
    when(specialParameters.getSpecialParameters()).thenReturn(specialParametersMap);
    when(specialParametersMap.get(anyString())).thenReturn(false);
    when(cloudParameterService.getOrchestrators()).thenReturn(platformOrchestrators);
    when(platformOrchestrators.getDefaults()).thenReturn(defaultOrchestrator);
    when(defaultOrchestrator.get(any(Platform.class))).thenReturn(orchestrator);
    when(instanceGroupToInstanceGroupParameterRequestConverter.convert(any(InstanceGroup.class))).thenReturn(instanceGroupParameterRequest);
    when(request.getCluster()).thenReturn(clusterRequest);
    when(environmentSettingsRequest.getCredentialName()).thenReturn(credentialName);
    when(sharedServiceValidator.checkSharedServiceStackRequirements(any(StackV4Request.class), any(Workspace.class))).thenReturn(validationResult);
    DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
    environmentResponse.setCredential(credentialResponse);
    CompactRegionResponse crr = new CompactRegionResponse();
    crr.setNames(Lists.newArrayList("region"));
    environmentResponse.setRegions(crr);
    EnvironmentNetworkResponse enr = new EnvironmentNetworkResponse();
    Map<String, CloudSubnet> subnetmetas = Maps.newHashMap("subnet", new CloudSubnet("id", "name", "availabilityzone", "cidr"));
    enr.setSubnetMetas(subnetmetas);
    environmentResponse.setNetwork(enr);
    environmentResponse.setAzure(AzureEnvironmentParameters.builder().withAzureResourceGroup(AzureResourceGroup.builder().withResourceGroupUsage(ResourceGroupUsage.SINGLE).withName("resource-group").build()).build());
    when(request.getCloudPlatform()).thenReturn(CloudPlatform.AZURE);
    when(environmentClientService.getByName(anyString())).thenReturn(environmentResponse);
    when(environmentClientService.getByCrn(anyString())).thenReturn(environmentResponse);
    Credential credential = Credential.builder().cloudPlatform(CloudPlatform.MOCK.name()).build();
    when(credentialClientService.getByCrn(anyString())).thenReturn(credential);
    when(credentialClientService.getByName(anyString())).thenReturn(credential);
    when(credentialConverter.convert(credentialResponse)).thenReturn(credential);
    ExtendedCloudCredential extendedCloudCredential = mock(ExtendedCloudCredential.class);
    when(extendedCloudCredentialConverter.convert(credential)).thenReturn(extendedCloudCredential);
}
Also used : CompactRegionResponse(com.sequenceiq.environment.api.v1.environment.model.response.CompactRegionResponse) ExtendedCloudCredential(com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential) ExtendedCloudCredential(com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential) Credential(com.sequenceiq.cloudbreak.dto.credential.Credential) Platform(com.sequenceiq.cloudbreak.cloud.model.Platform) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) Before(org.junit.Before)

Example 12 with CompactRegionResponse

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

the class RegionConverter method convertRegions.

public CompactRegionResponse convertRegions(Set<Region> regions) {
    CompactRegionResponse compactRegionResponse = new CompactRegionResponse();
    List<String> values = new ArrayList<>();
    Map<String, String> displayNames = new HashMap<>();
    for (Region region : regions) {
        values.add(region.getName());
        displayNames.put(region.getName(), region.getDisplayName());
    }
    compactRegionResponse.setNames(values);
    compactRegionResponse.setDisplayNames(displayNames);
    return compactRegionResponse;
}
Also used : CompactRegionResponse(com.sequenceiq.environment.api.v1.environment.model.response.CompactRegionResponse) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Region(com.sequenceiq.environment.environment.domain.Region)

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