use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-bpmn-model by camunda.
the class ProcessBuilderTest method testCreateEmptyProcess.
@Test
public void testCreateEmptyProcess() {
modelInstance = Bpmn.createProcess().done();
Definitions definitions = modelInstance.getDefinitions();
assertThat(definitions).isNotNull();
assertThat(definitions.getTargetNamespace()).isEqualTo(BPMN20_NS);
Collection<ModelElementInstance> processes = modelInstance.getModelElementsByType(processType);
assertThat(processes).hasSize(1);
Process process = (Process) processes.iterator().next();
assertThat(process.getId()).isNotNull();
}
use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-bpmn-model by camunda.
the class ExtensionElementsImpl method addExtensionElement.
public <T extends ModelElementInstance> T addExtensionElement(Class<T> extensionElementClass) {
ModelElementInstance extensionElement = modelInstance.newInstance(extensionElementClass);
addChildElement(extensionElement);
return extensionElementClass.cast(extensionElement);
}
use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-bpm-platform by camunda.
the class UserTaskBpmnModelExecutionContextTest method assertUserTask.
private void assertUserTask(String eventName) {
UserTask userTask = ModelExecutionContextTaskListener.userTask;
assertNotNull(userTask);
ModelElementInstance taskListener = userTask.getExtensionElements().getUniqueChildElementByNameNs(CAMUNDA_NS, "taskListener");
assertEquals(eventName, taskListener.getAttributeValueNs(CAMUNDA_NS, "event"));
assertEquals(ModelExecutionContextTaskListener.class.getName(), taskListener.getAttributeValueNs(CAMUNDA_NS, "class"));
BpmnModelInstance modelInstance = ModelExecutionContextTaskListener.modelInstance;
Collection<ModelElementInstance> tasks = modelInstance.getModelElementsByType(modelInstance.getModel().getType(Task.class));
assertTrue(tasks.contains(userTask));
}
use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-bpm-platform by camunda.
the class UserTaskBpmnModelExecutionContextTest method deployProcess.
private void deployProcess(String eventName) {
BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(PROCESS_ID).startEvent().userTask(USER_TASK_ID).endEvent().done();
ExtensionElements extensionElements = modelInstance.newInstance(ExtensionElements.class);
ModelElementInstance taskListener = extensionElements.addExtensionElement(CAMUNDA_NS, "taskListener");
taskListener.setAttributeValueNs(CAMUNDA_NS, "class", ModelExecutionContextTaskListener.class.getName());
taskListener.setAttributeValueNs(CAMUNDA_NS, "event", eventName);
UserTask userTask = modelInstance.getModelElementById(USER_TASK_ID);
userTask.setExtensionElements(extensionElements);
deploymentId = repositoryService.createDeployment().addModelInstance("process.bpmn", modelInstance).deploy().getId();
}
use of org.camunda.bpm.model.xml.instance.ModelElementInstance in project camunda-bpm-platform by camunda.
the class CmmnModelElementInstanceCmdTest method testRepositoryService.
@Deployment(resources = "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn")
public void testRepositoryService() {
String caseDefinitionId = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(CASE_KEY).singleResult().getId();
CmmnModelInstance modelInstance = repositoryService.getCmmnModelInstance(caseDefinitionId);
assertNotNull(modelInstance);
Collection<ModelElementInstance> humanTasks = modelInstance.getModelElementsByType(modelInstance.getModel().getType(HumanTask.class));
assertEquals(1, humanTasks.size());
Collection<ModelElementInstance> planItems = modelInstance.getModelElementsByType(modelInstance.getModel().getType(PlanItem.class));
assertEquals(1, planItems.size());
Collection<ModelElementInstance> cases = modelInstance.getModelElementsByType(modelInstance.getModel().getType(Case.class));
assertEquals(1, cases.size());
}
Aggregations