use of org.camunda.bpm.model.xml.testmodel.instance.Bird in project camunda-xml-model by camunda.
the class ModelElementInstanceTest method createModel.
private static Object[] createModel() {
TestModelParser modelParser = new TestModelParser();
ModelInstance modelInstance = modelParser.getEmptyModel();
Animals animals = modelInstance.newInstance(Animals.class);
modelInstance.setDocumentElement(animals);
createBird(modelInstance, "tweety", Gender.Female);
Bird donald = createBird(modelInstance, "donald", Gender.Male);
Bird daisy = createBird(modelInstance, "daisy", Gender.Female);
Bird hedwig = createBird(modelInstance, "hedwig", Gender.Male);
donald.setTextContent("some text content");
daisy.setTextContent("\n some text content with outer line breaks\n ");
hedwig.setTextContent("\n some text content with inner\n line breaks\n ");
return new Object[] { "created", modelInstance, modelParser };
}
use of org.camunda.bpm.model.xml.testmodel.instance.Bird in project camunda-xml-model by camunda.
the class ModelElementInstanceTest method testReplaceWithElement.
@Test
public void testReplaceWithElement() {
Bird timmy = modelInstance.newInstance(Bird.class);
timmy.setId("timmy");
timmy.setGender(Gender.Male);
assertThat(animals.getAnimals()).contains(tweety).doesNotContain(timmy);
tweety.replaceWithElement(timmy);
assertThat(animals.getAnimals()).contains(timmy).doesNotContain(tweety);
}
use of org.camunda.bpm.model.xml.testmodel.instance.Bird in project camunda-xml-model by camunda.
the class ModelElementInstanceTest method TestParentElement.
@Test
public void TestParentElement() {
assertThat(tweety.getParentElement()).isEqualTo(animals);
assertThat(donald.getParentElement()).isEqualTo(animals);
assertThat(daisy.getParentElement()).isEqualTo(animals);
assertThat(hedwig.getParentElement()).isEqualTo(animals);
Bird timmy = modelInstance.newInstance(Bird.class);
timmy.setId("timmy");
timmy.setGender(Gender.Male);
assertThat(timmy.getParentElement()).isNull();
}
use of org.camunda.bpm.model.xml.testmodel.instance.Bird in project camunda-xml-model by camunda.
the class ModelValidationTest method shouldReturnResults.
@Test
public void shouldReturnResults() {
List<ModelElementValidator<?>> validators = new ArrayList<ModelElementValidator<?>>();
validators.add(new IllegalBirdValidator("tweety"));
validators.add(new IsAdultWarner());
ValidationResults results = modelInstance.validate(validators);
assertThat(results.getErrorCount()).isEqualTo(1);
assertThat(results.getWarinigCount()).isEqualTo(7);
Map<ModelElementInstance, List<ValidationResult>> resultsByElement = results.getResults();
assertThat(resultsByElement.size()).isEqualTo(7);
for (Entry<ModelElementInstance, List<ValidationResult>> resultEntry : resultsByElement.entrySet()) {
Bird element = (Bird) resultEntry.getKey();
List<ValidationResult> validationResults = resultEntry.getValue();
assertThat(element).isNotNull();
assertThat(validationResults).isNotNull();
if (element.getId().equals("tweety")) {
assertThat(validationResults.size()).isEqualTo(2);
ValidationResult error = validationResults.remove(0);
assertThat(error.getType()).isEqualTo(ValidationResultType.ERROR);
assertThat(error.getCode()).isEqualTo(20);
assertThat(error.getMessage()).isEqualTo("Bird tweety is illegal");
assertThat(error.getElement()).isEqualTo(element);
} else {
assertThat(validationResults.size()).isEqualTo(1);
}
ValidationResult warning = validationResults.get(0);
assertThat(warning.getType()).isEqualTo(ValidationResultType.WARNING);
assertThat(warning.getCode()).isEqualTo(10);
assertThat(warning.getMessage()).isEqualTo("Is not an adult");
assertThat(warning.getElement()).isEqualTo(element);
}
}
Aggregations