Search in sources :

Example 26 with TopologyDTO

use of alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.

the class WorkflowStepDefinitions method the_workflow_step_has_no_followers.

@Then("^The workflow step \"(.*?)\" has no followers$")
public void the_workflow_step_has_no_followers(String stepId) throws Throwable {
    String topologyResponseText = Context.getInstance().getRestResponse();
    RestResponse<TopologyDTO> topologyResponse = JsonUtil.read(topologyResponseText, TopologyDTO.class, Context.getJsonMapper());
    String workflowName = Context.getInstance().getCurrentWorkflowName();
    Workflow workflow = topologyResponse.getData().getTopology().getWorkflows().get(workflowName);
    WorkflowStep step = workflow.getSteps().get(stepId);
    assertTrue(step.getOnSuccess() == null || step.getOnSuccess().isEmpty());
}
Also used : TopologyDTO(alien4cloud.topology.TopologyDTO) WorkflowStep(org.alien4cloud.tosca.model.workflow.WorkflowStep) Workflow(org.alien4cloud.tosca.model.workflow.Workflow) Then(cucumber.api.java.en.Then)

Example 27 with TopologyDTO

use of alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.

the class WorkflowStepDefinitions method the_workflow_step_has_no_predecessors.

@Then("^The workflow step \"(.*?)\" has no predecessors$")
public void the_workflow_step_has_no_predecessors(String stepId) throws Throwable {
    String topologyResponseText = Context.getInstance().getRestResponse();
    RestResponse<TopologyDTO> topologyResponse = JsonUtil.read(topologyResponseText, TopologyDTO.class, Context.getJsonMapper());
    String workflowName = Context.getInstance().getCurrentWorkflowName();
    Workflow workflow = topologyResponse.getData().getTopology().getWorkflows().get(workflowName);
    WorkflowStep step = workflow.getSteps().get(stepId);
    assertTrue(step.getPrecedingSteps() == null || step.getPrecedingSteps().isEmpty());
}
Also used : TopologyDTO(alien4cloud.topology.TopologyDTO) WorkflowStep(org.alien4cloud.tosca.model.workflow.WorkflowStep) Workflow(org.alien4cloud.tosca.model.workflow.Workflow) Then(cucumber.api.java.en.Then)

Example 28 with TopologyDTO

use of alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.

the class TopologyDTOBuilder method buildTopologyDTO.

/**
 * Build a topology dto (topology and all used types) out of a topology.
 *
 * @param context The edition context from which to build the dto.
 */
@ToscaContextual
public TopologyDTO buildTopologyDTO(EditionContext context) {
    TopologyDTO topologyDTO = new TopologyDTO();
    initTopologyDTO(context.getTopology(), topologyDTO);
    topologyDTO.setArchiveContentTree(context.getArchiveContentTree());
    topologyDTO.setLastOperationIndex(context.getLastOperationIndex());
    topologyDTO.setOperations(context.getOperations());
    topologyDTO.setDelegateType(context.getCsar().getDelegateType());
    topologyDTO.setDependencyConflicts(getDependencyConflictDTOs(context));
    // FIXME add validation information
    return topologyDTO;
}
Also used : AbstractTopologyDTO(alien4cloud.topology.AbstractTopologyDTO) TopologyDTO(alien4cloud.topology.TopologyDTO) ToscaContextual(alien4cloud.tosca.context.ToscaContextual)

Example 29 with TopologyDTO

use of alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.

the class EditorStepDefs method doExecuteOperation.

private void doExecuteOperation(AbstractEditorOperation operation, String topologyId) {
    thrownException = null;
    operation.setPreviousOperationId(topologyIdToLastOperationId.get(topologyId));
    try {
        TopologyDTO topologyDTO = editorService.execute(topologyId, operation);
        String lastOperationId = topologyDTO.getOperations().get(topologyDTO.getLastOperationIndex()).getId();
        topologyIdToLastOperationId.put(topologyId, lastOperationId);
        topologyEvaluationContext = new StandardEvaluationContext(topologyDTO.getTopology());
        dtoEvaluationContext = new StandardEvaluationContext(topologyDTO);
    } catch (Exception e) {
        log.error("Exception occurred while executing operation", e);
        thrownException = e;
        exceptionEvaluationContext = new StandardEvaluationContext(e);
    }
}
Also used : StandardEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext) TopologyDTO(alien4cloud.topology.TopologyDTO) NotFoundException(alien4cloud.exception.NotFoundException) IOException(java.io.IOException)

Example 30 with TopologyDTO

use of alien4cloud.topology.TopologyDTO in project alien4cloud by alien4cloud.

the class EditorStepDefs method iResetTheTopology.

@When("^I reset the topology$")
public void iResetTheTopology() throws Throwable {
    thrownException = null;
    try {
        TopologyDTO dto = editorService.reset(topologyIds.getLast(), topologyIdToLastOperationId.get(topologyIds.getLast()));
        topologyIdToLastOperationId.put(topologyIds.getLast(), null);
        dtoEvaluationContext = new StandardEvaluationContext(dto);
        topologyEvaluationContext = new StandardEvaluationContext(dto.getTopology());
    } catch (Exception e) {
        log.error("Error occurred when resetting the topology", e);
        thrownException = e;
        exceptionEvaluationContext = new StandardEvaluationContext(e);
    }
}
Also used : StandardEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext) TopologyDTO(alien4cloud.topology.TopologyDTO) NotFoundException(alien4cloud.exception.NotFoundException) IOException(java.io.IOException) When(cucumber.api.java.en.When)

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