Search in sources :

Example 1 with Context

use of alien4cloud.it.Context in project alien4cloud by alien4cloud.

the class DeploymentTopologyStepDefinitions method I_substitute_on_the_current_application_the_node_with_the_location_resource.

@When("^I substitute on the current application the node \"(.*?)\" with the location resource \"(.*?)\"/\"(.*?)\"/\"(.*?)\"$")
public void I_substitute_on_the_current_application_the_node_with_the_location_resource(String nodeName, String orchestratorName, String locationName, String resourceName) throws Throwable {
    Context context = Context.getInstance();
    String orchestratorId = context.getOrchestratorId(orchestratorName);
    String locationId = context.getLocationId(orchestratorId, locationName);
    String resourceId = context.getLocationResourceId(orchestratorId, locationId, resourceName);
    doNodeSubstitution(nodeName, resourceId);
}
Also used : EvaluationContext(org.springframework.expression.EvaluationContext) Context(alien4cloud.it.Context) StandardEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext) When(cucumber.api.java.en.When)

Example 2 with Context

use of alien4cloud.it.Context in project alien4cloud by alien4cloud.

the class DeploymentTopologyStepDefinitions method i_update_the_capability_property_to_for_the_subtituted_node.

@When("^I update the capability \"(.*?)\" property \"(.*?)\" to \"(.*?)\" for the subtituted node \"(.*?)\"$")
public void i_update_the_capability_property_to_for_the_subtituted_node(String capabilityName, String propertyName, String propertyValue, String nodeName) throws Throwable {
    Context context = Context.getInstance();
    Application application = context.getApplication();
    String envId = context.getDefaultApplicationEnvironmentId(application.getName());
    UpdatePropertyRequest request = new UpdatePropertyRequest(propertyName, propertyValue);
    String restUrl = String.format("/rest/v1/applications/%s/environments/%s/deployment-topology/substitutions/%s/capabilities/%s/properties", application.getId(), envId, nodeName, capabilityName);
    String response = Context.getRestClientInstance().postJSon(restUrl, JsonUtil.toString(request));
    context.registerRestResponse(response);
}
Also used : EvaluationContext(org.springframework.expression.EvaluationContext) Context(alien4cloud.it.Context) StandardEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext) UpdatePropertyRequest(alien4cloud.rest.topology.UpdatePropertyRequest) Application(alien4cloud.model.application.Application) When(cucumber.api.java.en.When)

Example 3 with Context

use of alien4cloud.it.Context in project alien4cloud by alien4cloud.

the class DeploymentTopologyStepDefinitions method I_substitute_on_the_current_application_the_policy_with_the_location_resource.

@When("^I substitute on the current application the policy \"(.*?)\" with the location resource \"(.*?)\"/\"(.*?)\"/\"(.*?)\"$")
public void I_substitute_on_the_current_application_the_policy_with_the_location_resource(String policyName, String orchestratorName, String locationName, String resourceName) throws Throwable {
    Context context = Context.getInstance();
    String orchestratorId = context.getOrchestratorId(orchestratorName);
    String locationId = context.getLocationId(orchestratorId, locationName);
    String resourceId = context.getLocationResourceId(orchestratorId, locationId, resourceName);
    doPolicySubstitution(policyName, resourceId);
}
Also used : EvaluationContext(org.springframework.expression.EvaluationContext) Context(alien4cloud.it.Context) StandardEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext) When(cucumber.api.java.en.When)

Example 4 with Context

use of alien4cloud.it.Context 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()));
    }
}
Also used : EvaluationContext(org.springframework.expression.EvaluationContext) Context(alien4cloud.it.Context) StandardEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext) DeploymentTopologyDTO(alien4cloud.deployment.DeploymentTopologyDTO) Then(cucumber.api.java.en.Then)

Example 5 with Context

use of alien4cloud.it.Context in project alien4cloud by alien4cloud.

the class DeploymentTopologyStepDefinitions method updateProperty.

private void updateProperty(String propertyName, Object propertyValue, String nodeName, String endpoint) throws IOException {
    Context context = Context.getInstance();
    Application application = context.getApplication();
    String envId = context.getDefaultApplicationEnvironmentId(application.getName());
    UpdatePropertyRequest request = new UpdatePropertyRequest(propertyName, propertyValue);
    String restUrl = String.format(endpoint, application.getId(), envId, nodeName);
    String response = Context.getRestClientInstance().postJSon(restUrl, JsonUtil.toString(request));
    context.registerRestResponse(response);
}
Also used : EvaluationContext(org.springframework.expression.EvaluationContext) Context(alien4cloud.it.Context) StandardEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext) UpdatePropertyRequest(alien4cloud.rest.topology.UpdatePropertyRequest) Application(alien4cloud.model.application.Application)

Aggregations

Context (alien4cloud.it.Context)6 EvaluationContext (org.springframework.expression.EvaluationContext)6 StandardEvaluationContext (org.springframework.expression.spel.support.StandardEvaluationContext)6 Application (alien4cloud.model.application.Application)3 When (cucumber.api.java.en.When)3 UpdatePropertyRequest (alien4cloud.rest.topology.UpdatePropertyRequest)2 DeploymentTopologyDTO (alien4cloud.deployment.DeploymentTopologyDTO)1 Then (cucumber.api.java.en.Then)1 NameValuePair (org.apache.http.NameValuePair)1 BasicNameValuePair (org.apache.http.message.BasicNameValuePair)1