Search in sources :

Example 46 with RelationshipTemplate

use of org.alien4cloud.tosca.model.templates.RelationshipTemplate 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 47 with RelationshipTemplate

use of org.alien4cloud.tosca.model.templates.RelationshipTemplate 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

RelationshipTemplate (org.alien4cloud.tosca.model.templates.RelationshipTemplate)47 NodeTemplate (org.alien4cloud.tosca.model.templates.NodeTemplate)37 Map (java.util.Map)12 Capability (org.alien4cloud.tosca.model.templates.Capability)12 RelationshipType (org.alien4cloud.tosca.model.types.RelationshipType)11 NodeType (org.alien4cloud.tosca.model.types.NodeType)9 AbstractPropertyValue (org.alien4cloud.tosca.model.definitions.AbstractPropertyValue)7 NotFoundException (alien4cloud.exception.NotFoundException)6 PaaSRelationshipTemplate (alien4cloud.paas.model.PaaSRelationshipTemplate)4 LinkedHashMap (java.util.LinkedHashMap)4 Topology (org.alien4cloud.tosca.model.templates.Topology)4 AlreadyExistException (alien4cloud.exception.AlreadyExistException)3 ParsingError (alien4cloud.tosca.parser.ParsingError)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Interface (org.alien4cloud.tosca.model.definitions.Interface)3 RequirementDefinition (org.alien4cloud.tosca.model.definitions.RequirementDefinition)3 Requirement (org.alien4cloud.tosca.model.templates.Requirement)3 CapabilityType (org.alien4cloud.tosca.model.types.CapabilityType)3 Workflow (org.alien4cloud.tosca.model.workflow.Workflow)3