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()));
}
}
}
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);
}
}
}
Aggregations