Search in sources :

Example 6 with TopologyDTO

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

the class InputPropertiesStepDefinitions method getPropertyDefinition.

private PropertyDefinition getPropertyDefinition(String nodeName, String propertyName) throws Throwable {
    PropertyDefinition propDef = null;
    String url = String.format("/rest/v1/topologies/%s", Context.getInstance().getTopologyId());
    String response = Context.getRestClientInstance().get(url);
    TopologyDTO topologyDTO = JsonUtil.read(response, TopologyDTO.class, Context.getJsonMapper()).getData();
    NodeTemplate template = MapUtils.getObject(topologyDTO.getTopology().getNodeTemplates(), nodeName);
    if (template != null) {
        NodeType nodeType = MapUtils.getObject(topologyDTO.getNodeTypes(), template.getType());
        if (nodeType != null) {
            propDef = MapUtils.getObject(nodeType.getProperties(), propertyName);
        }
    }
    if (propDef == null) {
        throw new NullPointerException("The property definition is required for node " + nodeName + " and property " + propertyName + ", please check your cucumber scenario.");
    }
    return propDef;
}
Also used : NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) TopologyDTO(alien4cloud.topology.TopologyDTO) NodeType(org.alien4cloud.tosca.model.types.NodeType) PropertyDefinition(org.alien4cloud.tosca.model.definitions.PropertyDefinition)

Example 7 with TopologyDTO

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

the class InputPropertiesStepDefinitions method i_define_the_capability_property_of_the_node_of_typeId_as_input_property.

@Given("^I define the capability \"(.*?)\" property \"(.*?)\" of the node \"(.*?)\" as input property$")
public void i_define_the_capability_property_of_the_node_of_typeId_as_input_property(String capabilityName, String propertyName, String nodeName) throws Throwable {
    String url = String.format("/rest/v1/topologies/%s", Context.getInstance().getTopologyId());
    String response = Context.getRestClientInstance().get(url);
    TopologyDTO topologyDTO = JsonUtil.read(response, TopologyDTO.class, Context.getJsonMapper()).getData();
    NodeTemplate template = MapUtils.getObject(topologyDTO.getTopology().getNodeTemplates(), nodeName);
    Capability capability = template.getCapabilities().get(capabilityName);
    CapabilityType capabilityType = topologyDTO.getCapabilityTypes().get(capability.getType());
    PropertyDefinition propertyDefinition = capabilityType.getProperties().get(propertyName);
    String fullUrl = String.format("/rest/v1/topologies/%s/inputs/%s", Context.getInstance().getTopologyId(), propertyName);
    String json = JsonUtil.toString(propertyDefinition);
    Context.getInstance().registerRestResponse(Context.getRestClientInstance().postJSon(fullUrl, json));
}
Also used : CapabilityType(org.alien4cloud.tosca.model.types.CapabilityType) NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) TopologyDTO(alien4cloud.topology.TopologyDTO) Capability(org.alien4cloud.tosca.model.templates.Capability) PropertyDefinition(org.alien4cloud.tosca.model.definitions.PropertyDefinition) Given(cucumber.api.java.en.Given)

Example 8 with TopologyDTO

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

the class OutputPropertiesStepDefinitions method The_topology_should_have_the_capability_property_of_the_capability_for_the_node_defined_as_output_property.

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

Example 9 with TopologyDTO

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

the class OutputPropertiesStepDefinitions method The_topology_should_not_have_the_attribute_of_the_node_defined_as_output_attribute.

@Then("^The topology should not have the attribute \"([^\"]*)\" of the node \"([^\"]*)\" defined as output attribute$")
public void The_topology_should_not_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();
    if (outputAttributes != null) {
        Set<String> outputAttributesOfNode = outputAttributes.get(nodeName);
        if (outputAttributesOfNode != null) {
            Assert.assertFalse(outputAttributesOfNode.contains(attributeName));
        }
    }
}
Also used : Set(java.util.Set) TopologyDTO(alien4cloud.topology.TopologyDTO) Then(cucumber.api.java.en.Then)

Example 10 with TopologyDTO

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

the class OutputPropertiesStepDefinitions method The_topology_should_not_have_the_property_of_the_node_defined_as_output_property.

@Then("^The topology should not have the property \"([^\"]*)\" of the node \"([^\"]*)\" defined as output property$")
public void The_topology_should_not_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();
    if (outputProperties != null) {
        Set<String> outputPropertiesOfNode = outputProperties.get(nodeName);
        if (outputPropertiesOfNode != null) {
            Assert.assertFalse(outputPropertiesOfNode.contains(propertyName));
        }
    }
}
Also used : Set(java.util.Set) 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