Search in sources :

Example 1 with ValidationResult

use of org.camunda.bpm.model.xml.validation.ValidationResult in project camunda-xml-model by camunda.

the class ModelValidationResultsImpl method write.

@Override
public void write(StringWriter writer, ValidationResultFormatter formatter) {
    for (Entry<ModelElementInstance, List<ValidationResult>> entry : collectedResults.entrySet()) {
        ModelElementInstance element = entry.getKey();
        List<ValidationResult> results = entry.getValue();
        formatter.formatElement(writer, element);
        for (ValidationResult result : results) {
            formatter.formatResult(writer, result);
        }
    }
}
Also used : ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) List(java.util.List) ValidationResult(org.camunda.bpm.model.xml.validation.ValidationResult)

Example 2 with ValidationResult

use of org.camunda.bpm.model.xml.validation.ValidationResult in project camunda-bpmn-model by camunda.

the class ValidateProcessTest method validationFailsIfNoStartEventFound.

@Test
public void validationFailsIfNoStartEventFound() {
    List<ModelElementValidator<?>> validators = new ArrayList<ModelElementValidator<?>>();
    validators.add(new ProcessStartEventValidator());
    BpmnModelInstance bpmnModelInstance = Bpmn.createProcess().done();
    ValidationResults validationResults = bpmnModelInstance.validate(validators);
    assertThat(validationResults.hasErrors()).isTrue();
    Map<ModelElementInstance, List<ValidationResult>> results = validationResults.getResults();
    assertThat(results.size()).isEqualTo(1);
    Process process = bpmnModelInstance.getDefinitions().getChildElementsByType(Process.class).iterator().next();
    assertThat(results.containsKey(process)).isTrue();
    List<ValidationResult> resultsForProcess = results.get(process);
    assertThat(resultsForProcess.size()).isEqualTo(1);
    ValidationResult validationResult = resultsForProcess.get(0);
    assertThat(validationResult.getElement()).isEqualTo(process);
    assertThat(validationResult.getCode()).isEqualTo(10);
    assertThat(validationResult.getMessage()).isEqualTo("Process does not have exactly one start event. Got 0.");
    assertThat(validationResult.getType()).isEqualTo(ValidationResultType.ERROR);
}
Also used : ModelElementValidator(org.camunda.bpm.model.xml.validation.ModelElementValidator) ValidationResults(org.camunda.bpm.model.xml.validation.ValidationResults) ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Process(org.camunda.bpm.model.bpmn.instance.Process) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) ValidationResult(org.camunda.bpm.model.xml.validation.ValidationResult) Test(org.junit.Test)

Aggregations

List (java.util.List)2 ModelElementInstance (org.camunda.bpm.model.xml.instance.ModelElementInstance)2 ValidationResult (org.camunda.bpm.model.xml.validation.ValidationResult)2 ArrayList (java.util.ArrayList)1 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)1 Process (org.camunda.bpm.model.bpmn.instance.Process)1 ModelElementValidator (org.camunda.bpm.model.xml.validation.ModelElementValidator)1 ValidationResults (org.camunda.bpm.model.xml.validation.ValidationResults)1 Test (org.junit.Test)1