Search in sources :

Example 41 with TopologyDTO

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

the class TopologyRecoveryStepDefinitions method the_node_in_the_topology_dto_should_have_relationshiptemplates.

@Then("^the node \"([^\"]*)\" in the topology dto should have (\\d+) relationshipTemplates$")
public void the_node_in_the_topology_dto_should_have_relationshiptemplates(String nodeName, int count) throws Throwable {
    TopologyDTO dto = JsonUtil.read(Context.getInstance().getRestResponse(), TopologyDTO.class, Context.getJsonMapper()).getData();
    NodeTemplate template = dto.getTopology().getNodeTemplates().get(nodeName);
    Assert.assertNotNull(template);
    Assert.assertEquals(count, template.getRelationships().size());
}
Also used : NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) TopologyDTO(alien4cloud.topology.TopologyDTO) Then(cucumber.api.java.en.Then)

Example 42 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_requirement.

@Then("^the node \"([^\"]*)\" in the topology dto should not have the requirement \"([^\"]*)\"$")
public void I_node_in_the_topology_dto_should_not_have_the_requirement(String nodeName, String requirementName) 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.getRequirements().containsKey(requirementName));
}
Also used : NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) TopologyDTO(alien4cloud.topology.TopologyDTO) Then(cucumber.api.java.en.Then)

Example 43 with TopologyDTO

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

the class TopologyRecoveryStepDefinitions method there_should_not_be_the_relationship_in_node_template_in_the_topology_dto.

@Then("^there should not be the relationship \"([^\"]*)\" in \"([^\"]*)\" node template in the topology dto$")
public void there_should_not_be_the_relationship_in_node_template_in_the_topology_dto(String relName, String nodeName) 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.getRelationships().containsKey(relName));
}
Also used : NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) TopologyDTO(alien4cloud.topology.TopologyDTO) Then(cucumber.api.java.en.Then)

Example 44 with TopologyDTO

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

the class WorkflowStepDefinitions method the_workflow_step_is_followed_by.

@When("^The workflow step \"(.*?)\" is followed by: (.*)$")
public void the_workflow_step_is_followed_by(String stepId, List<String> followers) 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> actualFollowers = step.getOnSuccess();
    assertNotNull(actualFollowers);
    assertEquals(followers.size(), actualFollowers.size());
    for (String expectedFollower : followers) {
        // we just remove the surrounding quotes
        String follower = expectedFollower.substring(1, expectedFollower.length() - 1);
        assertTrue(actualFollowers.contains(follower));
    }
}
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