Search in sources :

Example 1 with Model

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

the class ModelElementTypeAssert method isPartOfModel.

public ModelElementTypeAssert isPartOfModel(Model model) {
    isNotNull();
    Model actualModel = actual.getModel();
    if (!model.equals(actualModel)) {
        failWithMessage("Expected element type <%s> to be part of model <%s> but was part of <%s>", typeName, model.getModelName(), actualModel.getModelName());
    }
    return this;
}
Also used : Model(org.camunda.bpm.model.xml.Model)

Example 2 with Model

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

the class ModelBuilderTest method shouldSetModelName.

@Test
public void shouldSetModelName() {
    Model model = ModelBuilder.createInstance(MODEL_NAME).build();
    assertThat(model.getModelName()).isEqualTo(MODEL_NAME);
}
Also used : Model(org.camunda.bpm.model.xml.Model) Test(org.junit.Test)

Example 3 with Model

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

the class ModelElementInstanceImpl method getChildElementsByType.

public Collection<ModelElementInstance> getChildElementsByType(ModelElementType childElementType) {
    List<ModelElementInstance> instances = new ArrayList<ModelElementInstance>();
    for (ModelElementType extendingType : childElementType.getExtendingTypes()) {
        instances.addAll(getChildElementsByType(extendingType));
    }
    Model model = modelInstance.getModel();
    String alternativeNamespace = model.getAlternativeNamespace(childElementType.getTypeNamespace());
    List<DomElement> elements = domElement.getChildElementsByNameNs(asSet(childElementType.getTypeNamespace(), alternativeNamespace), childElementType.getTypeName());
    instances.addAll(ModelUtil.getModelElementCollection(elements, modelInstance));
    return instances;
}
Also used : ModelElementType(org.camunda.bpm.model.xml.type.ModelElementType) DomElement(org.camunda.bpm.model.xml.instance.DomElement) ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) ArrayList(java.util.ArrayList) Model(org.camunda.bpm.model.xml.Model)

Example 4 with Model

use of org.camunda.bpm.model.xml.Model in project camunda-bpmn-model by camunda.

the class ModelTest method testBaseTypeCalculation.

@Test
public void testBaseTypeCalculation() {
    BpmnModelInstance bpmnModelInstance = Bpmn.createEmptyModel();
    Model model = bpmnModelInstance.getModel();
    Collection<ModelElementType> allBaseTypes = ModelUtil.calculateAllBaseTypes(model.getType(StartEvent.class));
    assertThat(allBaseTypes).hasSize(5);
    allBaseTypes = ModelUtil.calculateAllBaseTypes(model.getType(MessageEventDefinition.class));
    assertThat(allBaseTypes).hasSize(3);
    allBaseTypes = ModelUtil.calculateAllBaseTypes(model.getType(BaseElement.class));
    assertThat(allBaseTypes).hasSize(0);
}
Also used : ModelElementType(org.camunda.bpm.model.xml.type.ModelElementType) Model(org.camunda.bpm.model.xml.Model) Test(org.junit.Test)

Example 5 with Model

use of org.camunda.bpm.model.xml.Model in project camunda-bpmn-model by camunda.

the class ModelTest method testExtendingTypeCalculation.

@Test
public void testExtendingTypeCalculation() {
    BpmnModelInstance bpmnModelInstance = Bpmn.createEmptyModel();
    Model model = bpmnModelInstance.getModel();
    List<ModelElementType> baseInstanceTypes = new ArrayList<ModelElementType>();
    baseInstanceTypes.add(model.getType(Event.class));
    baseInstanceTypes.add(model.getType(CatchEvent.class));
    baseInstanceTypes.add(model.getType(ExtensionElements.class));
    baseInstanceTypes.add(model.getType(EventDefinition.class));
    Collection<ModelElementType> allExtendingTypes = ModelUtil.calculateAllExtendingTypes(bpmnModelInstance.getModel(), baseInstanceTypes);
    assertThat(allExtendingTypes).hasSize(17);
}
Also used : ModelElementType(org.camunda.bpm.model.xml.type.ModelElementType) Model(org.camunda.bpm.model.xml.Model) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

Model (org.camunda.bpm.model.xml.Model)10 ModelElementInstance (org.camunda.bpm.model.xml.instance.ModelElementInstance)3 ModelElementType (org.camunda.bpm.model.xml.type.ModelElementType)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)2 Process (org.camunda.bpm.model.bpmn.instance.Process)2 DomElement (org.camunda.bpm.model.xml.instance.DomElement)2 Event (org.camunda.bpm.model.bpmn.instance.Event)1 ParallelGateway (org.camunda.bpm.model.bpmn.instance.ParallelGateway)1 ServiceTask (org.camunda.bpm.model.bpmn.instance.ServiceTask)1 Task (org.camunda.bpm.model.bpmn.instance.Task)1 ModelElementTypeImpl (org.camunda.bpm.model.xml.impl.type.ModelElementTypeImpl)1 BeforeClass (org.junit.BeforeClass)1