Search in sources :

Example 1 with Animals

use of org.camunda.bpm.model.xml.testmodel.instance.Animals in project camunda-xml-model by camunda.

the class DomTest method createModel.

private static Object[] createModel() {
    TestModelParser modelParser = new TestModelParser();
    ModelInstance modelInstance = modelParser.getEmptyModel();
    Animals animals = modelInstance.newInstance(Animals.class);
    modelInstance.setDocumentElement(animals);
    Description description = modelInstance.newInstance(Description.class);
    description.getDomElement().addCDataSection("CDATA <test>");
    animals.addChildElement(description);
    return new Object[] { "created", modelInstance, modelParser };
}
Also used : ModelInstance(org.camunda.bpm.model.xml.ModelInstance) Animals(org.camunda.bpm.model.xml.testmodel.instance.Animals) Description(org.camunda.bpm.model.xml.testmodel.instance.Description) TestModelParser(org.camunda.bpm.model.xml.testmodel.TestModelParser)

Example 2 with Animals

use of org.camunda.bpm.model.xml.testmodel.instance.Animals in project camunda-xml-model by camunda.

the class DomTest method testCData.

@Test
public void testCData() {
    Animals animals = (Animals) modelInstance.getDocumentElement();
    assertThat(animals.getDescription().getTextContent()).isEqualTo("CDATA <test>");
}
Also used : Animals(org.camunda.bpm.model.xml.testmodel.instance.Animals) Test(org.junit.Test) TestModelTest(org.camunda.bpm.model.xml.testmodel.TestModelTest)

Example 3 with Animals

use of org.camunda.bpm.model.xml.testmodel.instance.Animals 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 };
}
Also used : ModelInstance(org.camunda.bpm.model.xml.ModelInstance) Animals(org.camunda.bpm.model.xml.testmodel.instance.Animals) Bird(org.camunda.bpm.model.xml.testmodel.instance.Bird) TestModelParser(org.camunda.bpm.model.xml.testmodel.TestModelParser)

Example 4 with Animals

use of org.camunda.bpm.model.xml.testmodel.instance.Animals in project camunda-xml-model by camunda.

the class ModelElementInstanceTest method testReplaceRootElement.

@Test
public void testReplaceRootElement() {
    assertThat(((Animals) modelInstance.getDocumentElement()).getAnimals()).isNotEmpty();
    Animals newAnimals = modelInstance.newInstance(Animals.class);
    modelInstance.setDocumentElement(newAnimals);
    assertThat(((Animals) modelInstance.getDocumentElement()).getAnimals()).isEmpty();
}
Also used : Animals(org.camunda.bpm.model.xml.testmodel.instance.Animals) Test(org.junit.Test) TestModelTest(org.camunda.bpm.model.xml.testmodel.TestModelTest)

Example 5 with Animals

use of org.camunda.bpm.model.xml.testmodel.instance.Animals in project camunda-xml-model by camunda.

the class TestModelInstanceTest method testClone.

@Test
public void testClone() throws Exception {
    ModelInstance modelInstance = new TestModelParser().getEmptyModel();
    Animals animals = modelInstance.newInstance(Animals.class);
    modelInstance.setDocumentElement(animals);
    Animal animal = modelInstance.newInstance(Bird.class);
    animal.setId("TestId");
    animals.addChildElement(animal);
    ModelInstance cloneInstance = modelInstance.clone();
    getFirstAnimal(cloneInstance).setId("TestId2");
    assertThat(getFirstAnimal(modelInstance).getId(), is(equalTo("TestId")));
    assertThat(getFirstAnimal(cloneInstance).getId(), is(equalTo("TestId2")));
}
Also used : ModelInstance(org.camunda.bpm.model.xml.ModelInstance) Animals(org.camunda.bpm.model.xml.testmodel.instance.Animals) Animal(org.camunda.bpm.model.xml.testmodel.instance.Animal) Test(org.junit.Test)

Aggregations

Animals (org.camunda.bpm.model.xml.testmodel.instance.Animals)6 ModelInstance (org.camunda.bpm.model.xml.ModelInstance)4 TestModelParser (org.camunda.bpm.model.xml.testmodel.TestModelParser)3 Test (org.junit.Test)3 TestModelTest (org.camunda.bpm.model.xml.testmodel.TestModelTest)2 Animal (org.camunda.bpm.model.xml.testmodel.instance.Animal)1 Bird (org.camunda.bpm.model.xml.testmodel.instance.Bird)1 Description (org.camunda.bpm.model.xml.testmodel.instance.Description)1