Search in sources :

Example 11 with TopologyDTO

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()));
    }
}
Also used : NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) TopologyDTO(alien4cloud.topology.TopologyDTO) Map(java.util.Map) Then(cucumber.api.java.en.Then)

Example 12 with TopologyDTO

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);
}
Also used : TopologyDTO(alien4cloud.topology.TopologyDTO) Then(cucumber.api.java.en.Then)

Example 13 with TopologyDTO

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);
}
Also used : TopologyDTO(alien4cloud.topology.TopologyDTO) Then(cucumber.api.java.en.Then)

Example 14 with TopologyDTO

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);
}
Also used : ScalingPolicy(org.alien4cloud.tosca.model.templates.ScalingPolicy) TopologyDTO(alien4cloud.topology.TopologyDTO) Then(cucumber.api.java.en.Then)

Example 15 with TopologyDTO

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));
    }
}
Also used : NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) TopologyDTO(alien4cloud.topology.TopologyDTO) NodeGroup(org.alien4cloud.tosca.model.templates.NodeGroup) And(cucumber.api.java.en.And)

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