use of org.camunda.bpm.model.xml.validation.ValidationResults 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