@Test public void testBuildCloudInstanceParametersAzureMultipleResourceGroup() { InstanceMetaData metaData = new InstanceMetaData(); String fqdnParsedName = "test1-m-1-20180605095019"; metaData.setId(1L); metaData.setDiscoveryFQDN(String.format("%s.project.id", fqdnParsedName)); metaData.setSubnetId(TEST_STRING_ID); metaData.setInstanceName(TEST_NAME); DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse(); environmentResponse.setCloudPlatform("AZURE"); environmentResponse.setAzure(AzureEnvironmentParameters.builder() .withAzureResourceGroup(AzureResourceGroup.builder() .withResourceGroupUsage(ResourceGroupUsage.MULTIPLE) .build()) .build()); when(environmentClientService.getByCrn(anyString())).thenReturn(environmentResponse); Map<String, Object> result = underTest.buildCloudInstanceParameters(ENV_CRN, metaData, CloudPlatform.AZURE); assertFalse(result.containsKey(RESOURCE_GROUP_NAME_PARAMETER)); assertFalse(result.containsKey(RESOURCE_GROUP_USAGE_PARAMETER)); assertEquals(3, result.size()); }
public Map<String, Object> buildCloudInstanceParameters(String environmentCrn, InstanceMetaData instanceMetaData, CloudPlatform platform) { String hostName = instanceMetaData == null ? null : instanceMetaData.getShortHostname(); String subnetId = instanceMetaData == null ? null : instanceMetaData.getSubnetId(); String instanceName = instanceMetaData == null ? null : instanceMetaData.getInstanceName(); Map<String, Object> params = new HashMap<>(); if (hostName != null) { params.put(CloudInstance.DISCOVERY_NAME, hostName); } if (subnetId != null) { params.put(CloudInstance.SUBNET_ID, subnetId); } if (instanceName != null) { params.put(CloudInstance.INSTANCE_NAME, instanceName); } Optional<AzureResourceGroup> resourceGroupOptional = getAzureResourceGroup(environmentCrn, platform); if (resourceGroupOptional.isPresent() && !ResourceGroupUsage.MULTIPLE.equals(resourceGroupOptional.get().getResourceGroupUsage())) { AzureResourceGroup resourceGroup = resourceGroupOptional.get(); String resourceGroupName = resourceGroup.getName(); ResourceGroupUsage resourceGroupUsage = resourceGroup.getResourceGroupUsage(); params.put(RESOURCE_GROUP_NAME_PARAMETER, resourceGroupName); params.put(RESOURCE_GROUP_USAGE_PARAMETER, resourceGroupUsage.name()); } return params; }
StackToCloudStackConverter { public Map<String, Object> buildCloudInstanceParameters(String environmentCrn, InstanceMetaData instanceMetaData, CloudPlatform platform) { String hostName = instanceMetaData == null ? null : instanceMetaData.getShortHostname(); String subnetId = instanceMetaData == null ? null : instanceMetaData.getSubnetId(); String instanceName = instanceMetaData == null ? null : instanceMetaData.getInstanceName(); Map<String, Object> params = new HashMap<>(); if (hostName != null) { params.put(CloudInstance.DISCOVERY_NAME, hostName); } if (subnetId != null) { params.put(CloudInstance.SUBNET_ID, subnetId); } if (instanceName != null) { params.put(CloudInstance.INSTANCE_NAME, instanceName); } Optional<AzureResourceGroup> resourceGroupOptional = getAzureResourceGroup(environmentCrn, platform); if (resourceGroupOptional.isPresent() && !ResourceGroupUsage.MULTIPLE.equals(resourceGroupOptional.get().getResourceGroupUsage())) { AzureResourceGroup resourceGroup = resourceGroupOptional.get(); String resourceGroupName = resourceGroup.getName(); ResourceGroupUsage resourceGroupUsage = resourceGroup.getResourceGroupUsage(); params.put(RESOURCE_GROUP_NAME_PARAMETER, resourceGroupName); params.put(RESOURCE_GROUP_USAGE_PARAMETER, resourceGroupUsage.name()); } return params; } }
StackToCloudStackConverter { public Map<String, Object> buildCloudInstanceParameters(String environmentCrn, InstanceMetaData instanceMetaData, CloudPlatform platform) { String hostName = instanceMetaData == null ? null : instanceMetaData.getShortHostname(); String subnetId = instanceMetaData == null ? null : instanceMetaData.getSubnetId(); String instanceName = instanceMetaData == null ? null : instanceMetaData.getInstanceName(); Map<String, Object> params = new HashMap<>(); if (hostName != null) { params.put(CloudInstance.DISCOVERY_NAME, hostName); } if (subnetId != null) { params.put(CloudInstance.SUBNET_ID, subnetId); } if (instanceName != null) { params.put(CloudInstance.INSTANCE_NAME, instanceName); } Optional<AzureResourceGroup> resourceGroupOptional = getAzureResourceGroup(environmentCrn, platform); if (resourceGroupOptional.isPresent() && !ResourceGroupUsage.MULTIPLE.equals(resourceGroupOptional.get().getResourceGroupUsage())) { AzureResourceGroup resourceGroup = resourceGroupOptional.get(); String resourceGroupName = resourceGroup.getName(); ResourceGroupUsage resourceGroupUsage = resourceGroup.getResourceGroupUsage(); params.put(RESOURCE_GROUP_NAME_PARAMETER, resourceGroupName); params.put(RESOURCE_GROUP_USAGE_PARAMETER, resourceGroupUsage.name()); } return params; }  }
StackToCloudStackConverter { public Map<String, Object> buildCloudInstanceParameters(String environmentCrn, InstanceMetaData instanceMetaData, CloudPlatform platform) { String hostName = instanceMetaData == null ? null : instanceMetaData.getShortHostname(); String subnetId = instanceMetaData == null ? null : instanceMetaData.getSubnetId(); String instanceName = instanceMetaData == null ? null : instanceMetaData.getInstanceName(); Map<String, Object> params = new HashMap<>(); if (hostName != null) { params.put(CloudInstance.DISCOVERY_NAME, hostName); } if (subnetId != null) { params.put(CloudInstance.SUBNET_ID, subnetId); } if (instanceName != null) { params.put(CloudInstance.INSTANCE_NAME, instanceName); } Optional<AzureResourceGroup> resourceGroupOptional = getAzureResourceGroup(environmentCrn, platform); if (resourceGroupOptional.isPresent() && !ResourceGroupUsage.MULTIPLE.equals(resourceGroupOptional.get().getResourceGroupUsage())) { AzureResourceGroup resourceGroup = resourceGroupOptional.get(); String resourceGroupName = resourceGroup.getName(); ResourceGroupUsage resourceGroupUsage = resourceGroup.getResourceGroupUsage(); params.put(RESOURCE_GROUP_NAME_PARAMETER, resourceGroupName); params.put(RESOURCE_GROUP_USAGE_PARAMETER, resourceGroupUsage.name()); } return params; }  CloudStack convert(Stack stack); CloudStack convertForDownscale(Stack stack, Set<String> deleteRequestedInstances); CloudStack convertForTermination(Stack stack, String instanceId); CloudStack convert(Stack stack, Collection<String> deleteRequestedInstances); List<CloudInstance> buildInstances(Stack stack); CloudInstance buildInstance(InstanceMetaData instanceMetaData, InstanceGroup instanceGroup,
            StackAuthentication stackAuthentication, Long privateId, InstanceStatus status); Map<String, Object> buildCloudInstanceParameters(String environmentCrn, InstanceMetaData instanceMetaData, CloudPlatform platform); }
StackToCloudStackConverter { public Map<String, Object> buildCloudInstanceParameters(String environmentCrn, InstanceMetaData instanceMetaData, CloudPlatform platform) { String hostName = instanceMetaData == null ? null : instanceMetaData.getShortHostname(); String subnetId = instanceMetaData == null ? null : instanceMetaData.getSubnetId(); String instanceName = instanceMetaData == null ? null : instanceMetaData.getInstanceName(); Map<String, Object> params = new HashMap<>(); if (hostName != null) { params.put(CloudInstance.DISCOVERY_NAME, hostName); } if (subnetId != null) { params.put(CloudInstance.SUBNET_ID, subnetId); } if (instanceName != null) { params.put(CloudInstance.INSTANCE_NAME, instanceName); } Optional<AzureResourceGroup> resourceGroupOptional = getAzureResourceGroup(environmentCrn, platform); if (resourceGroupOptional.isPresent() && !ResourceGroupUsage.MULTIPLE.equals(resourceGroupOptional.get().getResourceGroupUsage())) { AzureResourceGroup resourceGroup = resourceGroupOptional.get(); String resourceGroupName = resourceGroup.getName(); ResourceGroupUsage resourceGroupUsage = resourceGroup.getResourceGroupUsage(); params.put(RESOURCE_GROUP_NAME_PARAMETER, resourceGroupName); params.put(RESOURCE_GROUP_USAGE_PARAMETER, resourceGroupUsage.name()); } return params; }  CloudStack convert(Stack stack); CloudStack convertForDownscale(Stack stack, Set<String> deleteRequestedInstances); CloudStack convertForTermination(Stack stack, String instanceId); CloudStack convert(Stack stack, Collection<String> deleteRequestedInstances); List<CloudInstance> buildInstances(Stack stack); CloudInstance buildInstance(InstanceMetaData instanceMetaData, InstanceGroup instanceGroup,
            StackAuthentication stackAuthentication, Long privateId, InstanceStatus status); Map<String, Object> buildCloudInstanceParameters(String environmentCrn, InstanceMetaData instanceMetaData, CloudPlatform platform);  }