Search in sources :

Example 36 with ModelElementInstance

use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-bpm-platform by camunda.

the class TransactionModels method makeCancelEvent.

protected static void makeCancelEvent(BpmnModelInstance model, String eventId) {
    ModelElementInstance element = model.getModelElementById(eventId);
    CancelEventDefinition eventDefinition = model.newInstance(CancelEventDefinition.class);
    element.addChildElement(eventDefinition);
}
Also used : ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) CancelEventDefinition(org.camunda.bpm.model.bpmn.instance.CancelEventDefinition)

Example 37 with ModelElementInstance

use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-bpm-platform by camunda.

the class ExecutionListenerBpmnModelExecutionContextTest method addExecutionListener.

private void addExecutionListener(BaseElement element, String eventName) {
    ExtensionElements extensionElements = element.getModelInstance().newInstance(ExtensionElements.class);
    ModelElementInstance executionListener = extensionElements.addExtensionElement(CAMUNDA_NS, "executionListener");
    executionListener.setAttributeValueNs(CAMUNDA_NS, "class", ModelExecutionContextExecutionListener.class.getName());
    executionListener.setAttributeValueNs(CAMUNDA_NS, "event", eventName);
    element.setExtensionElements(extensionElements);
}
Also used : ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance)

Example 38 with ModelElementInstance

use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-bpm-platform by camunda.

the class ExecutionListenerBpmnModelExecutionContextTest method assertFlowElementIs.

private void assertFlowElementIs(Class<? extends FlowElement> elementClass) {
    BpmnModelInstance modelInstance = ModelExecutionContextExecutionListener.modelInstance;
    assertNotNull(modelInstance);
    Model model = modelInstance.getModel();
    Collection<ModelElementInstance> events = modelInstance.getModelElementsByType(model.getType(Event.class));
    assertEquals(3, events.size());
    Collection<ModelElementInstance> gateways = modelInstance.getModelElementsByType(model.getType(Gateway.class));
    assertEquals(1, gateways.size());
    Collection<ModelElementInstance> tasks = modelInstance.getModelElementsByType(model.getType(Task.class));
    assertEquals(1, tasks.size());
    FlowElement flowElement = ModelExecutionContextExecutionListener.flowElement;
    assertNotNull(flowElement);
    assertTrue(elementClass.isAssignableFrom(flowElement.getClass()));
}
Also used : ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) ParallelGateway(org.camunda.bpm.model.bpmn.instance.ParallelGateway) Model(org.camunda.bpm.model.xml.Model) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance)

Example 39 with ModelElementInstance

use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-bpm-platform by camunda.

the class ServiceTaskBpmnModelExecutionContextTest method testJavaDelegateModelExecutionContext.

public void testJavaDelegateModelExecutionContext() {
    deploy();
    runtimeService.startProcessInstanceByKey(PROCESS_ID);
    BpmnModelInstance modelInstance = ModelExecutionContextServiceTask.modelInstance;
    assertNotNull(modelInstance);
    Model model = modelInstance.getModel();
    Collection<ModelElementInstance> events = modelInstance.getModelElementsByType(model.getType(Event.class));
    assertEquals(2, events.size());
    Collection<ModelElementInstance> tasks = modelInstance.getModelElementsByType(model.getType(Task.class));
    assertEquals(1, tasks.size());
    Process process = (Process) modelInstance.getDefinitions().getRootElements().iterator().next();
    assertEquals(PROCESS_ID, process.getId());
    assertTrue(process.isExecutable());
    ServiceTask serviceTask = ModelExecutionContextServiceTask.serviceTask;
    assertNotNull(serviceTask);
    assertEquals(ModelExecutionContextServiceTask.class.getName(), serviceTask.getCamundaClass());
}
Also used : ServiceTask(org.camunda.bpm.model.bpmn.instance.ServiceTask) Task(org.camunda.bpm.model.bpmn.instance.Task) ServiceTask(org.camunda.bpm.model.bpmn.instance.ServiceTask) ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) Model(org.camunda.bpm.model.xml.Model) Event(org.camunda.bpm.model.bpmn.instance.Event) Process(org.camunda.bpm.model.bpmn.instance.Process) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance)

Example 40 with ModelElementInstance

use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-dmn-model by camunda.

the class DmnModelTest method assertElementIsEqualToId.

protected void assertElementIsEqualToId(DmnModelElementInstance actualElement, String id) {
    assertThat(actualElement).isNotNull();
    ModelElementInstance expectedElement = modelInstance.getModelElementById(id);
    assertThat(expectedElement).isNotNull();
    assertThat(actualElement).isEqualTo(expectedElement);
}
Also used : DmnModelElementInstance(org.camunda.bpm.model.dmn.instance.DmnModelElementInstance) ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance)

Aggregations

ModelElementInstance (org.camunda.bpm.model.xml.instance.ModelElementInstance)55 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)8 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)8 ModelElementType (org.camunda.bpm.model.xml.type.ModelElementType)8 Process (org.camunda.bpm.model.bpmn.instance.Process)5 ModelInstanceImpl (org.camunda.bpm.model.xml.impl.ModelInstanceImpl)5 ModelReferenceException (org.camunda.bpm.model.xml.ModelReferenceException)4 DomElement (org.camunda.bpm.model.xml.instance.DomElement)4 List (java.util.List)3 Model (org.camunda.bpm.model.xml.Model)3 Deployment (org.camunda.bpm.engine.test.Deployment)2 Event (org.camunda.bpm.model.bpmn.instance.Event)2 SequenceFlow (org.camunda.bpm.model.bpmn.instance.SequenceFlow)2 BpmnShape (org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape)2 Case (org.camunda.bpm.model.cmmn.instance.Case)2 PlanItem (org.camunda.bpm.model.cmmn.instance.PlanItem)2 TestModelTest (org.camunda.bpm.model.xml.testmodel.TestModelTest)2 ModelElementValidator (org.camunda.bpm.model.xml.validation.ModelElementValidator)2 ValidationResult (org.camunda.bpm.model.xml.validation.ValidationResult)2