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;
}
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));
}
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));
}
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));
}
}
}
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));
}
}
}
Aggregations