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