use of alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.
the class TopologyStepDefinitions method I_should_have_a_relationship_with_type_from_to_in_ALIEN.
@Then("^I should have a relationship \"([^\"]*)\" with type \"([^\"]*)\" from \"([^\"]*)\" to \"([^\"]*)\" in ALIEN$")
public void I_should_have_a_relationship_with_type_from_to_in_ALIEN(String relName, String relType, String source, String target) throws Throwable {
// I should have a relationship with type
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);
relName = relName == null || relName.isEmpty() ? getRelationShipName(relType, target) : relName;
RelationshipTemplate rel = sourceNode.getRelationships().get(relName);
assertNotNull(rel);
assertEquals(relType, rel.getType());
assertEquals(target, rel.getTarget());
assertNotNull(rel.getRequirementName());
assertNotNull(rel.getRequirementType());
}
use of alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.
the class TopologyStepDefinitions method the_scaling_policy_of_the_node_should_match_max_instances_equals_to_initial_instances_equals_to_and_min_instances_equals_to.
@Then("^the scaling policy of the node \"([^\"]*)\" should match max instances equals to (\\d+), initial instances equals to (\\d+) and min instances equals to (\\d+)$")
public void the_scaling_policy_of_the_node_should_match_max_instances_equals_to_initial_instances_equals_to_and_min_instances_equals_to(String nodeName, int maxInstances, int initialInstances, int minInstances) throws Throwable {
I_try_to_retrieve_the_created_topology();
String topologyResponseText = Context.getInstance().getRestResponse();
RestResponse<TopologyDTO> topologyResponse = JsonUtil.read(topologyResponseText, TopologyDTO.class, Context.getJsonMapper());
assertNotNull(topologyResponse.getData());
ScalingPolicy computePolicy = TopologyUtils.getScalingPolicy(TopologyUtils.getScalableCapability(topologyResponse.getData().getTopology(), nodeName, true));
assertNotNull(computePolicy);
assertEquals(maxInstances, computePolicy.getMaxInstances());
assertEquals(minInstances, computePolicy.getMinInstances());
assertEquals(initialInstances, computePolicy.getInitialInstances());
}
use of alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.
the class TopologyStepDefinitions method The_RestResponse_should_contain_a_node_type_with_id.
@Then("^The RestResponse should contain a node type with \"([^\"]*)\" id$")
public void The_RestResponse_should_contain_a_node_type_with_id(String expectedId) throws Throwable {
TopologyDTO topologyDTO = JsonUtil.read(Context.getInstance().getRestResponse(), TopologyDTO.class, Context.getJsonMapper()).getData();
assertNotNull(topologyDTO);
assertNotNull(topologyDTO.getNodeTypes());
assertNotNull(topologyDTO.getNodeTypes().get(expectedId.split(":")[0]));
assertEquals(expectedId, topologyDTO.getNodeTypes().get(expectedId.split(":")[0]).getId());
}
use of alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.
the class SecretPropertiesStepDefinitions method theTopologyShouldHaveThePropertyDefinedAsASecretWithASecretPath.
@And("^The topology should have the property \"([^\"]*)\" of a node \"([^\"]*)\" defined as a secret with a secret path \"([^\"]*)\"$")
public void theTopologyShouldHaveThePropertyDefinedAsASecretWithASecretPath(String propertyName, String nodeName, String secretPath) throws Throwable {
String response = Context.getRestClientInstance().get("/rest/v1/topologies/" + Context.getInstance().getTopologyId());
JavaType restResponseType = Context.getJsonMapper().getTypeFactory().constructParametricType(RestResponse.class, TopologyDTO.class);
TopologyDTO topologyDTO = ((RestResponse<TopologyDTO>) Context.getJsonMapper().readValue(response, restResponseType)).getData();
FunctionPropertyValue functionPropertyValue = (FunctionPropertyValue) topologyDTO.getTopology().getNodeTemplates().get(nodeName).getProperties().get(propertyName);
Assert.assertEquals(secretPath, functionPropertyValue.getParameters().get(0));
}
use of alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.
the class SecretPropertiesStepDefinitions method theTopologyShouldHaveThePropertyOfCapabilityOfANodeDefinedAsASecretWithASecretPath.
@And("^The topology should have the property \"([^\"]*)\" of capability \"([^\"]*)\" of a node \"([^\"]*)\" defined as a secret with a secret path \"([^\"]*)\"$")
public void theTopologyShouldHaveThePropertyOfCapabilityOfANodeDefinedAsASecretWithASecretPath(String propertyName, String capabilityName, String nodeName, String secretPath) throws Throwable {
String response = Context.getRestClientInstance().get("/rest/v1/topologies/" + Context.getInstance().getTopologyId());
JavaType restResponseType = Context.getJsonMapper().getTypeFactory().constructParametricType(RestResponse.class, TopologyDTO.class);
TopologyDTO topologyDTO = ((RestResponse<TopologyDTO>) Context.getJsonMapper().readValue(response, restResponseType)).getData();
FunctionPropertyValue functionPropertyValue = (FunctionPropertyValue) topologyDTO.getTopology().getNodeTemplates().get(nodeName).getCapabilities().get(capabilityName).getProperties().get(propertyName);
Assert.assertEquals(secretPath, functionPropertyValue.getParameters().get(0));
}
Aggregations