Search in sources :

Example 1 with AbstractWorkflowError

use of alien4cloud.paas.wf.validation.AbstractWorkflowError in project alien4cloud by alien4cloud.

the class WorkflowPostProcessor method processWorkflowErrors.

private void processWorkflowErrors(Workflow wf, List<AbstractWorkflowError> errors, Node workflowNode) {
    for (AbstractWorkflowError error : errors) {
        if (error instanceof InlinedWorkflowNotFoundError) {
            Node node = ParsingContextExecution.getObjectToNodeMap().get(((InlinedWorkflowNotFoundError) error).getInlinedWorkflow());
            ParsingContextExecution.getParsingErrors().add(new ParsingError(ParsingErrorLevel.ERROR, ErrorCode.WORKFLOW_INLINED_WORKFLOW_NOT_FOUND, null, getSafeNodeStartMark(node), null, getSafeNodeEndMark(node), ((InlinedWorkflowNotFoundError) error).getInlinedWorkflow()));
        } else if (error instanceof UnknownNodeError) {
            Node node = ParsingContextExecution.getObjectToNodeMap().get(((UnknownNodeError) error).getNodeId());
            ParsingContextExecution.getParsingErrors().add(new ParsingError(ParsingErrorLevel.ERROR, ErrorCode.UNKNWON_WORKFLOW_STEP_TARGET, null, getSafeNodeStartMark(node), "The target node referenced by the workflow step do not exist.", getSafeNodeEndMark(node), ((UnknownNodeError) error).getNodeId()));
        } else if (error instanceof UnknownRelationshipError) {
            Node node = ParsingContextExecution.getObjectToNodeMap().get(((UnknownRelationshipError) error).getRelationshipId());
            ParsingContextExecution.getParsingErrors().add(new ParsingError(ParsingErrorLevel.ERROR, ErrorCode.UNKNWON_WORKFLOW_STEP_RELATIONSHIP_TARGET, null, getSafeNodeStartMark(node), "The target relationship referenced by the workflow step do not exist.", getSafeNodeEndMark(node), ((UnknownRelationshipError) error).getRelationshipId()));
        } else if (error instanceof WorkflowHasCycleError) {
            ParsingContextExecution.getParsingErrors().add(new ParsingError(ParsingErrorLevel.ERROR, ErrorCode.WORKFLOW_HAS_CYCLE, null, getSafeNodeStartMark(workflowNode), null, getSafeNodeEndMark(workflowNode), wf.getName()));
        } else {
            ParsingContextExecution.getParsingErrors().add(new ParsingError(ParsingErrorLevel.WARNING, ErrorCode.WORKFLOW_HAS_ERRORS, null, getSafeNodeStartMark(workflowNode), null, getSafeNodeEndMark(workflowNode), wf.getName()));
        }
    }
}
Also used : InlinedWorkflowNotFoundError(alien4cloud.paas.wf.validation.InlinedWorkflowNotFoundError) ParsingError(alien4cloud.tosca.parser.ParsingError) AbstractWorkflowError(alien4cloud.paas.wf.validation.AbstractWorkflowError) WorkflowHasCycleError(alien4cloud.paas.wf.validation.WorkflowHasCycleError) Node(org.yaml.snakeyaml.nodes.Node) UnknownRelationshipError(alien4cloud.paas.wf.validation.UnknownRelationshipError) UnknownNodeError(alien4cloud.paas.wf.validation.UnknownNodeError)

Example 2 with AbstractWorkflowError

use of alien4cloud.paas.wf.validation.AbstractWorkflowError in project alien4cloud by alien4cloud.

the class AbstractValidationTest method processValidation.

protected void processValidation(boolean workflowShouldHaveErrors, int errorCount) {
    log.info(WorkflowUtils.debugWorkflow(wf));
    if (workflowShouldHaveErrors && errorCount == 0 || !workflowShouldHaveErrors && errorCount > 0) {
        fail("Bad assertion");
    }
    List<AbstractWorkflowError> errors = getRule().validate(null, wf);
    if (errors != null) {
        wf.addErrors(errors);
    }
    assertEquals(workflowShouldHaveErrors, wf.hasErrors());
    if (errorCount > 0) {
        assertNotNull(wf.getErrors());
        assertEquals(errorCount, wf.getErrors().size());
        for (AbstractWorkflowError e : wf.getErrors()) {
            log.info("Workflow validation error is : " + e);
        }
    }
}
Also used : AbstractWorkflowError(alien4cloud.paas.wf.validation.AbstractWorkflowError)

Aggregations

AbstractWorkflowError (alien4cloud.paas.wf.validation.AbstractWorkflowError)2 InlinedWorkflowNotFoundError (alien4cloud.paas.wf.validation.InlinedWorkflowNotFoundError)1 UnknownNodeError (alien4cloud.paas.wf.validation.UnknownNodeError)1 UnknownRelationshipError (alien4cloud.paas.wf.validation.UnknownRelationshipError)1 WorkflowHasCycleError (alien4cloud.paas.wf.validation.WorkflowHasCycleError)1 ParsingError (alien4cloud.tosca.parser.ParsingError)1 Node (org.yaml.snakeyaml.nodes.Node)1