Search in sources :

Example 6 with ValidationError

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);
}
Also used : ValidationError(org.activiti.validation.ValidationError)

Example 7 with ValidationError

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;
}
Also used : ArrayList(java.util.ArrayList) Process(org.activiti.bpmn.model.Process) ValidationError(org.activiti.validation.ValidationError)

Example 8 with ValidationError

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;
}
Also used : ValidationError(org.activiti.validation.ValidationError)

Example 9 with ValidationError

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());
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) ValidationError(org.activiti.validation.ValidationError) XMLInputFactory(javax.xml.stream.XMLInputFactory) BpmnModel(org.activiti.bpmn.model.BpmnModel) BpmnXMLConverter(org.activiti.bpmn.converter.BpmnXMLConverter) Test(org.junit.Test)

Example 10 with ValidationError

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());
    }
}
Also used : ValidationError(org.activiti.validation.ValidationError) BpmnModel(org.activiti.bpmn.model.BpmnModel) Test(org.junit.Test)

Aggregations

ValidationError (org.activiti.validation.ValidationError)10 BpmnModel (org.activiti.bpmn.model.BpmnModel)4 Test (org.junit.Test)4 BpmnXMLConverter (org.activiti.bpmn.converter.BpmnXMLConverter)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStreamReader (java.io.InputStreamReader)2 XMLInputFactory (javax.xml.stream.XMLInputFactory)2 XMLStreamReader (javax.xml.stream.XMLStreamReader)2 FlowElement (org.activiti.bpmn.model.FlowElement)2 ProcessValidator (org.activiti.validation.ProcessValidator)2 InputStream (java.io.InputStream)1 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 XMLException (org.activiti.bpmn.exceptions.XMLException)1 Process (org.activiti.bpmn.model.Process)1 UserTask (org.activiti.bpmn.model.UserTask)1 ActivitiException (org.activiti.engine.ActivitiException)1 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)1 ProcessEngineConfigurationImpl (org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl)1 ProcessValidatorFactory (org.activiti.validation.ProcessValidatorFactory)1