Search in sources :

Example 36 with TopologyDTO

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

the class OutputPropertiesStepDefinitions method The_topology_should_have_the_attribute_of_the_node_defined_as_output_attribute.

@Then("^The topology should have the attribute \"([^\"]*)\" of the node \"([^\"]*)\" defined as output attribute$")
public void The_topology_should_have_the_attribute_of_the_node_defined_as_output_attribute(String attributeName, String nodeName) throws Throwable {
    TopologyDTO topologyDTO = getTopologyDTO();
    Map<String, Set<String>> outputAttributes = topologyDTO.getTopology().getOutputAttributes();
    Assert.assertNotNull(outputAttributes);
    Set<String> outputAttributesOfNode = outputAttributes.get(nodeName);
    Assert.assertNotNull(outputAttributesOfNode);
    Assert.assertTrue(outputAttributesOfNode.contains(attributeName));
}
Also used : Set(java.util.Set) TopologyDTO(alien4cloud.topology.TopologyDTO) Then(cucumber.api.java.en.Then)

Example 37 with TopologyDTO

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

the class OutputPropertiesStepDefinitions method The_topology_should_have_the_property_of_the_node_defined_as_output_property.

@Then("^The topology should have the property \"([^\"]*)\" of the node \"([^\"]*)\" defined as output property$")
public void The_topology_should_have_the_property_of_the_node_defined_as_output_property(String propertyName, String nodeName) throws Throwable {
    TopologyDTO topologyDTO = getTopologyDTO();
    Map<String, Set<String>> outputProperties = topologyDTO.getTopology().getOutputProperties();
    Assert.assertNotNull(outputProperties);
    Set<String> outputPropertiesOfNode = outputProperties.get(nodeName);
    Assert.assertNotNull(outputPropertiesOfNode);
    Assert.assertTrue(outputPropertiesOfNode.contains(propertyName));
}
Also used : Set(java.util.Set) TopologyDTO(alien4cloud.topology.TopologyDTO) Then(cucumber.api.java.en.Then)

Example 38 with TopologyDTO

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

the class TopologyStepDefinitions method The_RestResponse_should_contain_a_nodetemplate_named_and_type.

@Then("^The RestResponse should contain a nodetemplate named \"([^\"]*)\" and type \"([^\"]*)\"")
public void The_RestResponse_should_contain_a_nodetemplate_named_and_type(String key, String type) throws Throwable {
    TopologyDTO topologyDTO = JsonUtil.read(Context.getInstance().getRestResponse(), TopologyDTO.class, Context.getJsonMapper()).getData();
    assertNotNull(topologyDTO);
    assertNotNull(topologyDTO.getTopology());
    assertNotNull(topologyDTO.getTopology().getNodeTemplates());
    assertEquals(type, topologyDTO.getTopology().getNodeTemplates().get(key).getType());
}
Also used : TopologyDTO(alien4cloud.topology.TopologyDTO) Then(cucumber.api.java.en.Then)

Example 39 with TopologyDTO

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

the class TopologyStepDefinitions method I_should_have_relationship_with_source_for_requirement_of_type.

@Then("^I should have (\\d+) relationship with source \"([^\"]*)\" and target \"([^\"]*)\" for type \"([^\"]*)\" with requirement \"([^\"]*)\" of type \"([^\"]*)\"$")
public void I_should_have_relationship_with_source_for_requirement_of_type(int relationshipCount, String source, String target, String relType, String requirementName, String requirementType) throws Throwable {
    String topologyJson = Context.getRestClientInstance().get("/rest/v1/topologies/" + Context.getInstance().getTopologyId());
    RestResponse<TopologyDTO> topologyResponse = JsonUtil.read(topologyJson, TopologyDTO.class, Context.getJsonMapper());
    NodeTemplate sourceNode = topologyResponse.getData().getTopology().getNodeTemplates().get(source);
    RelationshipTemplate rel = sourceNode.getRelationships().get(getRelationShipName(relType, target));
    assertNotNull(rel);
    // Only one relationship of this type for the moment : cardinality check soon
    assertEquals(rel.getRequirementName(), requirementName);
    assertEquals(rel.getRequirementType(), requirementType);
}
Also used : NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) RelationshipTemplate(org.alien4cloud.tosca.model.templates.RelationshipTemplate) TopologyDTO(alien4cloud.topology.TopologyDTO) Then(cucumber.api.java.en.Then)

Example 40 with TopologyDTO

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

the class NodeTemplateStepDefinitions method I_should_not_have_a_relationship_in_node_template.

@Then("^I should not have the relationship \"([^\"]*)\" in \"([^\"]*)\" node template$")
public void I_should_not_have_a_relationship_in_node_template(String relName, String nodeTempName) throws Throwable {
    String topologyJson = Context.getRestClientInstance().get("/rest/v1/topologies/" + Context.getInstance().getTopologyId());
    RestResponse<TopologyDTO> topologyResponse = JsonUtil.read(topologyJson, TopologyDTO.class, Context.getJsonMapper());
    NodeTemplate sourceNode = topologyResponse.getData().getTopology().getNodeTemplates().get(nodeTempName);
    Map<String, RelationshipTemplate> rels = sourceNode.getRelationships();
    if (rels != null) {
        assertFalse(rels.containsKey(relName));
    } else {
        log.info("No relationship found in I_should_not_have_a_relationship_in_node_template(String relName, String nodeTempName)");
    }
}
Also used : NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) RelationshipTemplate(org.alien4cloud.tosca.model.templates.RelationshipTemplate) TopologyDTO(alien4cloud.topology.TopologyDTO) Then(cucumber.api.java.en.Then)

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