Search in sources :

Example 1 with TestModelParser

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

the class AnimalTest method createModel.

public static Object[] createModel() {
    TestModelParser modelParser = new TestModelParser();
    ModelInstance modelInstance = modelParser.getEmptyModel();
    Animals animals = modelInstance.newInstance(Animals.class);
    modelInstance.setDocumentElement(animals);
    // add a tns namespace prefix for QName testing
    animals.getDomElement().registerNamespace("tns", MODEL_NAMESPACE);
    Animal tweety = createBird(modelInstance, "tweety", Gender.Female);
    Animal hedwig = createBird(modelInstance, "hedwig", Gender.Male);
    Animal birdo = createBird(modelInstance, "birdo", Gender.Female);
    Animal plucky = createBird(modelInstance, "plucky", Gender.Unknown);
    Animal fiffy = createBird(modelInstance, "fiffy", Gender.Female);
    createBird(modelInstance, "timmy", Gender.Male);
    createBird(modelInstance, "daisy", Gender.Female);
    // create and add some relationships
    RelationshipDefinition hedwigRelationship = createRelationshipDefinition(modelInstance, hedwig, ChildRelationshipDefinition.class);
    addRelationshipDefinition(tweety, hedwigRelationship);
    RelationshipDefinition birdoRelationship = createRelationshipDefinition(modelInstance, birdo, ChildRelationshipDefinition.class);
    addRelationshipDefinition(tweety, birdoRelationship);
    RelationshipDefinition pluckyRelationship = createRelationshipDefinition(modelInstance, plucky, FriendRelationshipDefinition.class);
    addRelationshipDefinition(tweety, pluckyRelationship);
    RelationshipDefinition fiffyRelationship = createRelationshipDefinition(modelInstance, fiffy, FriendRelationshipDefinition.class);
    addRelationshipDefinition(tweety, fiffyRelationship);
    tweety.getRelationshipDefinitionRefs().add(hedwigRelationship);
    tweety.getRelationshipDefinitionRefs().add(birdoRelationship);
    tweety.getRelationshipDefinitionRefs().add(pluckyRelationship);
    tweety.getRelationshipDefinitionRefs().add(fiffyRelationship);
    tweety.getBestFriends().add(birdo);
    tweety.getBestFriends().add(plucky);
    return new Object[] { "created", modelInstance, modelParser };
}
Also used : ModelInstance(org.camunda.bpm.model.xml.ModelInstance) TestModelParser(org.camunda.bpm.model.xml.testmodel.TestModelParser)

Example 2 with TestModelParser

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

the class BirdTest method createModel.

public static Object[] createModel() {
    TestModelParser modelParser = new TestModelParser();
    ModelInstance modelInstance = modelParser.getEmptyModel();
    Animals animals = modelInstance.newInstance(Animals.class);
    modelInstance.setDocumentElement(animals);
    // add a tns namespace prefix for QName testing
    animals.getDomElement().registerNamespace("tns", MODEL_NAMESPACE);
    Bird tweety = createBird(modelInstance, "tweety", Gender.Female);
    Bird hedwig = createBird(modelInstance, "hedwig", Gender.Female);
    Bird timmy = createBird(modelInstance, "timmy", Gender.Female);
    Egg egg1 = createEgg(modelInstance, "egg1");
    egg1.setMother(tweety);
    Collection<Animal> guards = egg1.getGuardians();
    guards.add(hedwig);
    guards.add(timmy);
    Egg egg2 = createEgg(modelInstance, "egg2");
    egg2.setMother(tweety);
    guards = egg2.getGuardians();
    guards.add(hedwig);
    guards.add(timmy);
    Egg egg3 = createEgg(modelInstance, "egg3");
    guards = egg3.getGuardians();
    guards.add(timmy);
    tweety.setSpouse(hedwig);
    tweety.getEggs().add(egg1);
    tweety.getEggs().add(egg2);
    tweety.getEggs().add(egg3);
    Collection<Egg> guardedEggs = hedwig.getGuardedEggs();
    guardedEggs.add(egg1);
    guardedEggs.add(egg2);
    GuardEgg guardEgg = modelInstance.newInstance(GuardEgg.class);
    guardEgg.setTextContent(egg1.getId() + " " + egg2.getId());
    timmy.getGuardedEggRefs().add(guardEgg);
    timmy.getGuardedEggs().add(egg3);
    return new Object[] { "created", modelInstance, modelParser };
}
Also used : ModelInstance(org.camunda.bpm.model.xml.ModelInstance) TestModelParser(org.camunda.bpm.model.xml.testmodel.TestModelParser)

Example 3 with TestModelParser

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

the class FlyingAnimalTest method createModel.

public static Object[] createModel() {
    TestModelParser modelParser = new TestModelParser();
    ModelInstance modelInstance = modelParser.getEmptyModel();
    Animals animals = modelInstance.newInstance(Animals.class);
    modelInstance.setDocumentElement(animals);
    // add a tns namespace prefix for QName testing
    animals.getDomElement().registerNamespace("tns", MODEL_NAMESPACE);
    FlyingAnimal tweety = createBird(modelInstance, "tweety", Gender.Female);
    FlyingAnimal hedwig = createBird(modelInstance, "hedwig", Gender.Male);
    FlyingAnimal birdo = createBird(modelInstance, "birdo", Gender.Female);
    FlyingAnimal plucky = createBird(modelInstance, "plucky", Gender.Unknown);
    FlyingAnimal fiffy = createBird(modelInstance, "fiffy", Gender.Female);
    createBird(modelInstance, "timmy", Gender.Male);
    createBird(modelInstance, "daisy", Gender.Female);
    tweety.setFlightInstructor(hedwig);
    tweety.getFlightPartnerRefs().add(hedwig);
    tweety.getFlightPartnerRefs().add(birdo);
    tweety.getFlightPartnerRefs().add(plucky);
    tweety.getFlightPartnerRefs().add(fiffy);
    return new Object[] { "created", modelInstance, modelParser };
}
Also used : ModelInstance(org.camunda.bpm.model.xml.ModelInstance) TestModelParser(org.camunda.bpm.model.xml.testmodel.TestModelParser)

Example 4 with TestModelParser

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

the class UnknownAnimalTest method parseModel.

@Before
public void parseModel() {
    modelParser = new TestModelParser();
    String testXml = this.getClass().getSimpleName() + ".xml";
    InputStream testXmlAsStream = this.getClass().getResourceAsStream(testXml);
    modelInstance = modelParser.parseModelFromStream(testXmlAsStream);
    wanda = modelInstance.getModelElementById("wanda");
    flipper = modelInstance.getModelElementById("flipper");
}
Also used : InputStream(java.io.InputStream) TestModelParser(org.camunda.bpm.model.xml.testmodel.TestModelParser) Before(org.junit.Before)

Example 5 with TestModelParser

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

the class ChildElementCollectionTest method createModel.

public static Object[] createModel() {
    TestModelParser modelParser = new TestModelParser();
    ModelInstance modelInstance = modelParser.getEmptyModel();
    Animals animals = modelInstance.newInstance(Animals.class);
    modelInstance.setDocumentElement(animals);
    Bird tweety = createBird(modelInstance, "tweety", Gender.Female);
    Bird daffy = createBird(modelInstance, "daffy", Gender.Male);
    Bird daisy = createBird(modelInstance, "daisy", Gender.Female);
    Bird plucky = createBird(modelInstance, "plucky", Gender.Male);
    createBird(modelInstance, "birdo", Gender.Female);
    tweety.setFlightInstructor(daffy);
    tweety.getFlightPartnerRefs().add(daisy);
    tweety.getFlightPartnerRefs().add(plucky);
    return new Object[] { "created", modelInstance, modelParser };
}
Also used : ModelInstance(org.camunda.bpm.model.xml.ModelInstance) TestModelParser(org.camunda.bpm.model.xml.testmodel.TestModelParser)

Aggregations

TestModelParser (org.camunda.bpm.model.xml.testmodel.TestModelParser)11 ModelInstance (org.camunda.bpm.model.xml.ModelInstance)8 Animals (org.camunda.bpm.model.xml.testmodel.instance.Animals)3 Before (org.junit.Before)3 InputStream (java.io.InputStream)2 Bird (org.camunda.bpm.model.xml.testmodel.instance.Bird)1 Description (org.camunda.bpm.model.xml.testmodel.instance.Description)1