use of org.alien4cloud.tosca.model.templates.NodeTemplate 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 org.alien4cloud.tosca.model.templates.NodeTemplate 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 org.alien4cloud.tosca.model.templates.NodeTemplate in project alien4cloud by alien4cloud.
the class TopologyCompareStepsDefinitions method quickCompareTopologies.
@Then("^Topologies \"([^\"]*)\" and \"([^\"]*)\" have the same number of node templates with identical types.$")
public void quickCompareTopologies(String topologyId1, String topologyId2) throws Throwable {
// created topology
Context.getInstance().registerRestResponse(getRestClientInstance().get("/rest/v1/topologies/" + topologyId1));
TopologyDTO topology1 = JsonUtil.read(Context.getInstance().getRestResponse(), TopologyDTO.class, Context.getJsonMapper()).getData();
Context.getInstance().registerRestResponse(getRestClientInstance().get("/rest/v1/topologies/" + topologyId2));
TopologyDTO topology2 = JsonUtil.read(Context.getInstance().getRestResponse(), TopologyDTO.class, Context.getJsonMapper()).getData();
// node templates count test
assertNotNull(topology2);
assertNotNull(topology1);
int topo2nodeCount = topology2.getTopology() == null || topology2.getTopology().getNodeTemplates() == null ? 0 : topology2.getTopology().getNodeTemplates().size();
int topo1nodeCount = topology1.getTopology() == null || topology1.getTopology().getNodeTemplates() == null ? 0 : topology1.getTopology().getNodeTemplates().size();
assertEquals(topo2nodeCount, topo1nodeCount);
if (topo2nodeCount == 0) {
return;
}
// node templates name / type test
for (Map.Entry<String, NodeTemplate> entry : topology1.getTopology().getNodeTemplates().entrySet()) {
assertTrue(topology2.getTopology().getNodeTemplates().containsKey(entry.getKey()));
assertTrue(topology2.getTopology().getNodeTemplates().get(entry.getKey()).getType().equals(entry.getValue().getType()));
}
}
use of org.alien4cloud.tosca.model.templates.NodeTemplate in project alien4cloud by alien4cloud.
the class TopologyStepDefinitions method The_topology_should_contain_a_nodetemplate_named_with_an_artifact_with_the_specified_UID.
@Then("^The topology should contain a nodetemplate named \"([^\"]*)\" with an artifact \"([^\"]*)\" with the specified UID and name \"([^\"]*)\"$")
public void The_topology_should_contain_a_nodetemplate_named_with_an_artifact_with_the_specified_UID(String nodeTemplateName, String artifactId, String artifactName) throws Throwable {
The_topology_should_contain_a_nodetemplate_named(nodeTemplateName);
String topologyResponseText = Context.getInstance().getRestResponse();
NodeTemplate nodeTemp = JsonUtil.read(topologyResponseText, TopologyDTO.class, Context.getJsonMapper()).getData().getTopology().getNodeTemplates().get(nodeTemplateName);
Assert.assertNotNull(nodeTemp.getArtifacts());
Assert.assertFalse(nodeTemp.getArtifacts().isEmpty());
DeploymentArtifact deploymentArtifact = nodeTemp.getArtifacts().get(artifactId);
Assert.assertNotNull(deploymentArtifact);
Assert.assertNotNull(deploymentArtifact.getArtifactType());
Assert.assertEquals(artifactName, deploymentArtifact.getArtifactName());
}
use of org.alien4cloud.tosca.model.templates.NodeTemplate in project alien4cloud by alien4cloud.
the class TopologyStepDefinitions method The_topology_should_contain_a_nodetemplate_named_with_property_set_to.
@Then("^The topology should contain a nodetemplate named \"([^\"]*)\" with property \"([^\"]*)\" set to \"([^\"]*)\"$")
public void The_topology_should_contain_a_nodetemplate_named_with_property_set_to(String nodeTemplateName, String propertyName, String propertyValue) throws Throwable {
The_topology_should_contain_a_nodetemplate_named(nodeTemplateName);
String topologyResponseText = Context.getInstance().getRestResponse();
NodeTemplate nodeTemp = JsonUtil.read(topologyResponseText, TopologyDTO.class, Context.getJsonMapper()).getData().getTopology().getNodeTemplates().get(nodeTemplateName);
assertNotNull(nodeTemp.getProperties());
if (propertyValue != null) {
assertNotNull(nodeTemp.getProperties().get(propertyName));
}
assertEquals(propertyValue, PropertyUtil.getScalarValue(nodeTemp.getProperties().get(propertyName)));
}
Aggregations