use of alien4cloud.deployment.DeploymentTopologyDTO in project alien4cloud by alien4cloud.
the class DeploymentTopologyController method getDeploymentTopology.
/**
* Get the deployment topology of an application given an environment
*
* @param appId application Id
* @param environmentId environment Id
* @return the deployment topology DTO
*/
@ApiOperation(value = "Get the deployment topology of an application given an environment.", notes = "Application role required [ APPLICATION_MANAGER | APPLICATION_DEVOPS ] and Application environment role required [ DEPLOYMENT_MANAGER ]")
@RequestMapping(value = "", method = RequestMethod.GET)
@PreAuthorize("isAuthenticated()")
public RestResponse<DeploymentTopologyDTO> getDeploymentTopology(@PathVariable String appId, @PathVariable String environmentId) {
Application application = applicationService.getOrFail(appId);
ApplicationEnvironment environment = appEnvironmentService.getOrFail(environmentId);
AuthorizationUtil.checkAuthorizationForEnvironment(application, environment);
ApplicationTopologyVersion topologyVersion = applicationVersionService.getOrFail(Csar.createId(environment.getApplicationId(), environment.getVersion()), environment.getTopologyVersion());
Topology topology = topologyServiceCore.getOrFail(topologyVersion.getArchiveId());
// This method prepares the deployment and create a Deployment Topology DTO object.
DeploymentTopologyDTO dto = deploymentTopologyDTOBuilder.prepareDeployment(topology, application, environment);
return RestResponseBuilder.<DeploymentTopologyDTO>builder().data(dto).build();
}
use of alien4cloud.deployment.DeploymentTopologyDTO in project alien4cloud by alien4cloud.
the class DeploymentTopologyStepDefinitions method The_deployment_topology_shoud_have_the_following_location_policies.
@Then("^the deployment topology shoud have the following location policies$")
public void The_deployment_topology_shoud_have_the_following_location_policies(DataTable expectedSettings) throws Throwable {
String response = Context.getInstance().getRestResponse();
RestResponse<DeploymentTopologyDTO> deploymentTopologyDTO = JsonUtil.read(response, DeploymentTopologyDTO.class, Context.getJsonMapper());
assertNotNull(deploymentTopologyDTO.getData());
Map<String, String> policies = deploymentTopologyDTO.getData().getLocationPolicies();
assertNotNull(policies);
Context context = Context.getInstance();
List<LocationPolicySetting> expectedLocationPoliciesSettings = convert(expectedSettings);
for (LocationPolicySetting expected : expectedLocationPoliciesSettings) {
String expectLocationId = context.getLocationId(context.getOrchestratorId(expected.getOrchestratorName()), expected.getLocationName());
assertEquals(expectLocationId, policies.get(expected.getGroupName()));
}
}
use of alien4cloud.deployment.DeploymentTopologyDTO in project alien4cloud by alien4cloud.
the class DeploymentTopologyStepDefinitions method getDTOAndassertNotNull.
private DeploymentTopologyDTO getDTOAndassertNotNull() throws IOException {
String response = Context.getInstance().getRestResponse();
DeploymentTopologyDTO dto = JsonUtil.read(response, DeploymentTopologyDTO.class, Context.getJsonMapper()).getData();
assertNotNull(dto);
return dto;
}
use of alien4cloud.deployment.DeploymentTopologyDTO in project alien4cloud by alien4cloud.
the class DeploymentTopologyStepDefinitions method theDeploymentTopologyShouldHaveAnInputPropertyWithTheFollowingParameters.
@And("^The deployment topology should have an input property \"([^\"]*)\" with the following parameters$")
public void theDeploymentTopologyShouldHaveAnInputPropertyWithTheFollowingParameters(String propertyName, Map<String, String> parameters) throws Throwable {
DeploymentTopologyDTO dto = getDeploymentTopologyDTO();
FunctionPropertyValue functionPropertyValue = (FunctionPropertyValue) safe(dto.getTopology().getAllInputProperties()).get(propertyName);
Assert.assertEquals(functionPropertyValue.getFunction(), parameters.get("functionName"));
Assert.assertEquals(functionPropertyValue.getParameters().get(0), parameters.get("secretPath"));
}
use of alien4cloud.deployment.DeploymentTopologyDTO in project alien4cloud by alien4cloud.
the class DeploymentTopologyStepDefinitions method checkSubstitutions.
private void checkSubstitutions(List<SubstitutionSetting> expectedSubstitutionSettings, ITemplateSubstitutionInfoAccessor substitutionsAccessor) throws IOException {
DeploymentTopologyDTO dto = getDTOAndassertNotNull();
Map<String, String> substitutions = substitutionsAccessor.getSubstitutions(dto);
Map<String, ? extends AbstractLocationResourceTemplate> resources = substitutionsAccessor.getSubstitutionTemplates(dto);
assertTrue(MapUtils.isNotEmpty(substitutions));
assertTrue(MapUtils.isNotEmpty(resources));
for (SubstitutionSetting substitutionSetting : expectedSubstitutionSettings) {
String substituteId = substitutions.get(substitutionSetting.getTemplateNme());
assertNotNull(substituteId);
AbstractLocationResourceTemplate substitute = resources.get(substituteId);
assertNotNull(substitute);
assertEquals(substitutionSetting.getResourceName(), substitute.getName());
assertEquals(substitutionSetting.getResourceType(), substitute.getTemplate().getType());
}
}
Aggregations