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);
}
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;
}
Aggregations