Search in sources :

Example 31 with ModelElementInstance

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();
}
Also used : ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) Process(org.camunda.bpm.model.bpmn.instance.Process) Test(org.junit.Test)

Example 32 with ModelElementInstance

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);
}
Also used : ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance)

Example 33 with ModelElementInstance

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));
}
Also used : ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance)

Example 34 with ModelElementInstance

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();
}
Also used : ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance)

Example 35 with ModelElementInstance

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());
}
Also used : ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) HumanTask(org.camunda.bpm.model.cmmn.instance.HumanTask) PlanItem(org.camunda.bpm.model.cmmn.instance.PlanItem) CmmnModelInstance(org.camunda.bpm.model.cmmn.CmmnModelInstance) Case(org.camunda.bpm.model.cmmn.instance.Case) PluggableProcessEngineTestCase(org.camunda.bpm.engine.impl.test.PluggableProcessEngineTestCase) Deployment(org.camunda.bpm.engine.test.Deployment)

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