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);
}
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);
}
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()));
}
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());
}
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);
}
Aggregations