Search in sources :

Example 21 with TopologyDTO

use of alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.

the class SecretPropertiesStepDefinitions method theTopologyShouldHaveThePropertyOfRelationshipFromTheNodeDefinedAsASecretWithASecretPath.

@And("^The topology should have the property \"([^\"]*)\" of relationship \"([^\"]*)\" from the node \"([^\"]*)\" defined as a secret with a secret path \"([^\"]*)\"$")
public void theTopologyShouldHaveThePropertyOfRelationshipFromTheNodeDefinedAsASecretWithASecretPath(String propertyName, String relationshipName, String nodeName, String secretPath) throws Throwable {
    String response = Context.getRestClientInstance().get("/rest/v1/topologies/" + Context.getInstance().getTopologyId());
    JavaType restResponseType = Context.getJsonMapper().getTypeFactory().constructParametricType(RestResponse.class, TopologyDTO.class);
    TopologyDTO topologyDTO = ((RestResponse<TopologyDTO>) Context.getJsonMapper().readValue(response, restResponseType)).getData();
    FunctionPropertyValue functionPropertyValue = (FunctionPropertyValue) topologyDTO.getTopology().getNodeTemplates().get(nodeName).getRelationships().get(relationshipName).getProperties().get(propertyName);
    Assert.assertEquals(secretPath, functionPropertyValue.getParameters().get(0));
}
Also used : JavaType(com.fasterxml.jackson.databind.JavaType) TopologyDTO(alien4cloud.topology.TopologyDTO) RestResponse(alien4cloud.rest.model.RestResponse) FunctionPropertyValue(org.alien4cloud.tosca.model.definitions.FunctionPropertyValue) And(cucumber.api.java.en.And)

Example 22 with TopologyDTO

use of alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.

the class TopologyRecoveryStepDefinitions method I_node_in_the_topology_dto_should_not_have_the_capability.

@Then("^the node \"([^\"]*)\" in the topology dto should not have the capability \"([^\"]*)\"$")
public void I_node_in_the_topology_dto_should_not_have_the_capability(String nodeName, String capabilityName) throws IOException {
    TopologyDTO dto = JsonUtil.read(Context.getInstance().getRestResponse(), TopologyDTO.class, Context.getJsonMapper()).getData();
    NodeTemplate template = dto.getTopology().getNodeTemplates().get(nodeName);
    Assert.assertNotNull(template);
    assertFalse(template.getCapabilities().containsKey(capabilityName));
}
Also used : NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) TopologyDTO(alien4cloud.topology.TopologyDTO) Then(cucumber.api.java.en.Then)

Example 23 with TopologyDTO

use of alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.

the class TopologyRecoveryStepDefinitions method the_topology_dto_should_contain_an_emty_topology.

@Then("^the topology dto should contain an emty topology$")
public void the_topology_dto_should_contain_an_emty_topology() throws Throwable {
    TopologyDTO dto = JsonUtil.read(Context.getInstance().getRestResponse(), TopologyDTO.class, Context.getJsonMapper()).getData();
    Assert.assertTrue(dto.getTopology().isEmpty());
}
Also used : TopologyDTO(alien4cloud.topology.TopologyDTO) Then(cucumber.api.java.en.Then)

Example 24 with TopologyDTO

use of alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.

the class TopologyRecoveryStepDefinitions method the_topology_dto_should_contain_nodetemplates.

@Then("^the topology dto should contain (\\d+) nodetemplates$")
public void the_topology_dto_should_contain_nodetemplates(int count) throws Throwable {
    TopologyDTO dto = JsonUtil.read(Context.getInstance().getRestResponse(), TopologyDTO.class, Context.getJsonMapper()).getData();
    Assert.assertEquals(count, dto.getTopology().getNodeTemplates().size());
}
Also used : TopologyDTO(alien4cloud.topology.TopologyDTO) Then(cucumber.api.java.en.Then)

Example 25 with TopologyDTO

use of alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.

the class WorkflowStepDefinitions method the_workflow_step_is_preceded_by.

@When("^The workflow step \"(.*?)\" is preceded by: (.*)$")
public void the_workflow_step_is_preceded_by(String stepId, List<String> predecesors) throws Throwable {
    String topologyResponseText = Context.getInstance().getRestResponse();
    RestResponse<TopologyDTO> topologyResponse = JsonUtil.read(topologyResponseText, TopologyDTO.class, Context.getJsonMapper());
    String workflowName = Context.getInstance().getCurrentWorkflowName();
    Workflow workflow = topologyResponse.getData().getTopology().getWorkflows().get(workflowName);
    WorkflowStep step = workflow.getSteps().get(stepId);
    Set<String> actualPredecessors = step.getPrecedingSteps();
    assertNotNull(actualPredecessors);
    assertEquals(predecesors.size(), actualPredecessors.size());
    for (String expectedPredecessor : predecesors) {
        // we just remove the surrounding quotes
        String predecessor = expectedPredecessor.substring(1, expectedPredecessor.length() - 1);
        assertTrue(actualPredecessors.contains(predecessor));
    }
}
Also used : TopologyDTO(alien4cloud.topology.TopologyDTO) WorkflowStep(org.alien4cloud.tosca.model.workflow.WorkflowStep) Workflow(org.alien4cloud.tosca.model.workflow.Workflow) When(cucumber.api.java.en.When)

Aggregations

TopologyDTO (alien4cloud.topology.TopologyDTO)44 Then (cucumber.api.java.en.Then)27 NodeTemplate (org.alien4cloud.tosca.model.templates.NodeTemplate)12 Set (java.util.Set)6 NotFoundException (alien4cloud.exception.NotFoundException)5 RestResponse (alien4cloud.rest.model.RestResponse)4 JavaType (com.fasterxml.jackson.databind.JavaType)4 And (cucumber.api.java.en.And)4 When (cucumber.api.java.en.When)4 Map (java.util.Map)4 PropertyDefinition (org.alien4cloud.tosca.model.definitions.PropertyDefinition)4 Workflow (org.alien4cloud.tosca.model.workflow.Workflow)4 WorkflowStep (org.alien4cloud.tosca.model.workflow.WorkflowStep)4 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 ApiOperation (io.swagger.annotations.ApiOperation)3 IOException (java.io.IOException)3 FunctionPropertyValue (org.alien4cloud.tosca.model.definitions.FunctionPropertyValue)3 RelationshipTemplate (org.alien4cloud.tosca.model.templates.RelationshipTemplate)3 StandardEvaluationContext (org.springframework.expression.spel.support.StandardEvaluationContext)3