use of org.activiti.validation.ValidationError in project Activiti by Activiti.
the class ValidatorImpl method addError.
protected void addError(List<ValidationError> validationErrors, String problem, Process process, String id, String description) {
ValidationError error = new ValidationError();
if (process != null) {
error.setProcessDefinitionId(process.getId());
error.setProcessDefinitionName(process.getName());
}
error.setProblem(problem);
error.setDefaultDescription(description);
error.setActivityId(id);
addError(validationErrors, error);
}
use of org.activiti.validation.ValidationError in project Activiti by Activiti.
the class ActivitiTestCaseProcessValidator method validate.
@Override
public List<ValidationError> validate(BpmnModel bpmnModel) {
List<ValidationError> errorList = new ArrayList<ValidationError>();
CustomParseValidator customParseValidator = new CustomParseValidator();
for (Process process : bpmnModel.getProcesses()) {
customParseValidator.executeParse(bpmnModel, process);
}
for (String errorRef : bpmnModel.getErrors().keySet()) {
ValidationError error = new ValidationError();
error.setValidatorSetName("Manual BPMN parse validator");
error.setProblem(errorRef);
error.setActivityId(bpmnModel.getErrors().get(errorRef));
errorList.add(error);
}
return errorList;
}
use of org.activiti.validation.ValidationError in project Activiti by Activiti.
the class DefaultProcessValidatorTest method findErrors.
protected List<ValidationError> findErrors(List<ValidationError> errors, String validatorSetName, String problemName, int expectedNrOfProblems) {
List<ValidationError> results = findErrors(errors, validatorSetName, problemName);
Assert.assertEquals(expectedNrOfProblems, results.size());
for (ValidationError result : results) {
Assert.assertEquals(validatorSetName, result.getValidatorSetName());
Assert.assertEquals(problemName, result.getProblem());
}
return results;
}
use of org.activiti.validation.ValidationError in project Activiti by Activiti.
the class DefaultProcessValidatorTest method testWarningError.
@Test
public void testWarningError() throws UnsupportedEncodingException, XMLStreamException {
String flowWithoutConditionNoDefaultFlow = "<?xml version='1.0' encoding='UTF-8'?>" + "<definitions id='definitions' xmlns='http://www.omg.org/spec/BPMN/20100524/MODEL' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:activiti='http://activiti.org/bpmn' targetNamespace='Examples'>" + " <process id='exclusiveGwDefaultSequenceFlow'> " + " <startEvent id='theStart' /> " + " <sequenceFlow id='flow1' sourceRef='theStart' targetRef='exclusiveGw' /> " + // no default = "flow3" !!
" <exclusiveGateway id='exclusiveGw' name='Exclusive Gateway' /> " + " <sequenceFlow id='flow2' sourceRef='exclusiveGw' targetRef='theTask1'> " + " <conditionExpression xsi:type='tFormalExpression'>${input == 1}</conditionExpression> " + " </sequenceFlow> " + // one would be OK
" <sequenceFlow id='flow3' sourceRef='exclusiveGw' targetRef='theTask2'/> " + // but two unconditional not!
" <sequenceFlow id='flow4' sourceRef='exclusiveGw' targetRef='theTask2'/> " + " <userTask id='theTask1' name='Input is one' /> " + " <userTask id='theTask2' name='Default input' /> " + " </process>" + "</definitions>";
XMLInputFactory xif = XMLInputFactory.newInstance();
InputStreamReader in = new InputStreamReader(new ByteArrayInputStream(flowWithoutConditionNoDefaultFlow.getBytes()), "UTF-8");
XMLStreamReader xtr = xif.createXMLStreamReader(in);
BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr);
Assert.assertNotNull(bpmnModel);
List<ValidationError> allErrors = processValidator.validate(bpmnModel);
Assert.assertEquals(1, allErrors.size());
Assert.assertTrue(allErrors.get(0).isWarning());
}
use of org.activiti.validation.ValidationError in project Activiti by Activiti.
the class DefaultProcessValidatorTest method testNonExecutableProcessDefinitionWarning.
/*
* Test for https://activiti.atlassian.net/browse/ACT-2071:
*
* If there is at least one process definition which is executable,
* and the deployment contains other process definitions which are not executable,
* then add a warning for those non executable process definitions
*/
@Test
public void testNonExecutableProcessDefinitionWarning() {
BpmnModel bpmnModel = new BpmnModel();
// 3 non-executables
for (int i = 0; i < 3; i++) {
org.activiti.bpmn.model.Process process = TestProcessUtil.createOneTaskProcess();
process.setExecutable(false);
bpmnModel.addProcess(process);
}
// 1 executables
org.activiti.bpmn.model.Process process = TestProcessUtil.createOneTaskProcess();
process.setExecutable(true);
bpmnModel.addProcess(process);
List<ValidationError> errors = processValidator.validate(bpmnModel);
Assert.assertEquals(3, errors.size());
for (ValidationError error : errors) {
Assert.assertTrue(error.isWarning());
Assert.assertNotNull(error.getValidatorSetName());
Assert.assertNotNull(error.getProblem());
Assert.assertNotNull(error.getDefaultDescription());
}
}
Aggregations