use of alien4cloud.topology.TopologyDTO 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 alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.
the class TopologyStepDefinitions method The_RestResponse_should_not_contain_a_relationship_of_type_with_source_and_target.
@Then("The RestResponse should not contain a relationship of type \"([^\"]*)\" with source \"([^\"]*)\" and target \"([^\"]*)\"")
public void The_RestResponse_should_not_contain_a_relationship_of_type_with_source_and_target(String type, String source, String target) throws Throwable {
TopologyDTO topologyDTO = JsonUtil.read(Context.getInstance().getRestResponse(), TopologyDTO.class, Context.getJsonMapper()).getData();
assertNotNull(topologyDTO);
assertNotNull(topologyDTO.getTopology());
assertNotNull(topologyDTO.getTopology().getNodeTemplates());
assertNotNull(topologyDTO.getTopology().getNodeTemplates().get(source));
assertNotNull(topologyDTO.getTopology().getNodeTemplates().get(source).getRelationships() == null || topologyDTO.getTopology().getNodeTemplates().get(source).getRelationships().get(getRelationShipName(type, target)) == null);
}
use of alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.
the class TopologyStepDefinitions method The_RestResponse_should_not_contain_a_nodetemplate_named.
@Then("^The RestResponse should not contain a nodetemplate named \"([^\"]*)\"")
public void The_RestResponse_should_not_contain_a_nodetemplate_named(String key) throws Throwable {
TopologyDTO topologyDTO = JsonUtil.read(Context.getInstance().getRestResponse(), TopologyDTO.class, Context.getJsonMapper()).getData();
assertNotNull(topologyDTO);
assertNotNull(topologyDTO.getTopology());
assertTrue(topologyDTO.getTopology().getNodeTemplates() == null || topologyDTO.getTopology().getNodeTemplates().get(key) == null);
}
use of alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.
the class TopologyStepDefinitions method There_s_no_defined_scaling_policy.
@Then("^There's no defined scaling policy for the node \"([^\"]*)\"$")
public void There_s_no_defined_scaling_policy(String nodeName) 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));
assertEquals(ScalingPolicy.NOT_SCALABLE_POLICY, computePolicy);
}
use of alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.
the class TopologyStepDefinitions method The_RestResponse_should_contain_a_group_named_whose_members_are_and_policy_is.
@And("^The RestResponse should contain a group named \"([^\"]*)\" whose members are \"([^\"]*)\" and policy is \"([^\"]*)\"$")
public void The_RestResponse_should_contain_a_group_named_whose_members_are_and_policy_is(String groupName, String members, String policy) throws Throwable {
String topologyResponseText = Context.getInstance().getRestResponse();
RestResponse<TopologyDTO> topologyResponse = JsonUtil.read(topologyResponseText, TopologyDTO.class, Context.getJsonMapper());
Assert.assertNotNull(topologyResponse.getData().getTopology().getGroups());
NodeGroup nodeGroup = topologyResponse.getData().getTopology().getGroups().get(groupName);
Set<String> expectedMembers = Sets.newHashSet(members.split(","));
Assert.assertNotNull(nodeGroup);
Assert.assertEquals(nodeGroup.getMembers(), expectedMembers);
Assert.assertEquals(nodeGroup.getPolicies().iterator().next().getType(), policy);
for (String expectedMember : expectedMembers) {
NodeTemplate nodeTemplate = topologyResponse.getData().getTopology().getNodeTemplates().get(expectedMember);
Assert.assertNotNull(nodeTemplate);
Assert.assertTrue(nodeTemplate.getGroups().contains(groupName));
}
}
Aggregations