Search in sources :

Example 1 with UserTask

use of org.camunda.bpm.model.bpmn.instance.UserTask in project camunda-bpmn-model by camunda.

the class ResourceRolesTest method testGetPotentialOwner.

@Test
public void testGetPotentialOwner() {
    UserTask userTask = modelInstance.getModelElementById("_9");
    Collection<ResourceRole> resourceRoles = userTask.getResourceRoles();
    assertThat(resourceRoles.size()).isEqualTo(1);
    ResourceRole resourceRole = resourceRoles.iterator().next();
    assertThat(resourceRole instanceof PotentialOwner).isTrue();
    assertThat(resourceRole.getName()).isEqualTo("Task potential owner");
}
Also used : ResourceRole(org.camunda.bpm.model.bpmn.instance.ResourceRole) UserTask(org.camunda.bpm.model.bpmn.instance.UserTask) PotentialOwner(org.camunda.bpm.model.bpmn.instance.PotentialOwner) Test(org.junit.Test)

Example 2 with UserTask

use of org.camunda.bpm.model.bpmn.instance.UserTask in project camunda-bpmn-model by camunda.

the class ResourceRolesTest method testGetHumanPerformer.

@Test
public void testGetHumanPerformer() {
    UserTask userTask = modelInstance.getModelElementById("_7");
    Collection<ResourceRole> resourceRoles = userTask.getResourceRoles();
    assertThat(resourceRoles.size()).isEqualTo(1);
    ResourceRole resourceRole = resourceRoles.iterator().next();
    assertThat(resourceRole instanceof HumanPerformer).isTrue();
    assertThat(resourceRole.getName()).isEqualTo("Task human performer");
}
Also used : ResourceRole(org.camunda.bpm.model.bpmn.instance.ResourceRole) UserTask(org.camunda.bpm.model.bpmn.instance.UserTask) HumanPerformer(org.camunda.bpm.model.bpmn.instance.HumanPerformer) Test(org.junit.Test)

Example 3 with UserTask

use of org.camunda.bpm.model.bpmn.instance.UserTask in project camunda-bpmn-model by camunda.

the class GenerateIdTest method shouldNotGenerateIdsOnRead.

@Test
public void shouldNotGenerateIdsOnRead() {
    BpmnModelInstance modelInstance = Bpmn.readModelFromStream(GenerateIdTest.class.getResourceAsStream("GenerateIdTest.bpmn"));
    Definitions definitions = modelInstance.getDefinitions();
    assertThat(definitions.getId()).isNull();
    Process process = modelInstance.getModelElementsByType(Process.class).iterator().next();
    assertThat(process.getId()).isNull();
    StartEvent startEvent = modelInstance.getModelElementsByType(StartEvent.class).iterator().next();
    assertThat(startEvent.getId()).isNull();
    UserTask userTask = modelInstance.getModelElementsByType(UserTask.class).iterator().next();
    assertThat(userTask.getId()).isNull();
}
Also used : Definitions(org.camunda.bpm.model.bpmn.instance.Definitions) StartEvent(org.camunda.bpm.model.bpmn.instance.StartEvent) UserTask(org.camunda.bpm.model.bpmn.instance.UserTask) Process(org.camunda.bpm.model.bpmn.instance.Process) Test(org.junit.Test)

Example 4 with UserTask

use of org.camunda.bpm.model.bpmn.instance.UserTask in project camunda-bpm-platform by camunda.

the class MigrationUserTaskTest method addTaskListener.

protected static void addTaskListener(BpmnModelInstance targetModel, String activityId, String event, String className) {
    CamundaTaskListener taskListener = targetModel.newInstance(CamundaTaskListener.class);
    taskListener.setCamundaClass(className);
    taskListener.setCamundaEvent(event);
    UserTask task = targetModel.getModelElementById(activityId);
    task.builder().addExtensionElement(taskListener);
}
Also used : CamundaTaskListener(org.camunda.bpm.model.bpmn.instance.camunda.CamundaTaskListener) UserTask(org.camunda.bpm.model.bpmn.instance.UserTask)

Example 5 with UserTask

use of org.camunda.bpm.model.bpmn.instance.UserTask in project camunda-bpm-platform by camunda.

the class MigrationUserTaskTest method testAccessModelInTaskListenerAfterMigration.

@Test
public void testAccessModelInTaskListenerAfterMigration() {
    BpmnModelInstance targetModel = modify(ProcessModels.ONE_TASK_PROCESS).changeElementId("userTask", "newUserTask");
    addTaskListener(targetModel, "newUserTask", TaskListener.EVENTNAME_ASSIGNMENT, AccessModelInstanceTaskListener.class.getName());
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(targetModel);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask", "newUserTask").build();
    ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // when
    Task task = rule.getTaskService().createTaskQuery().singleResult();
    rule.getTaskService().setAssignee(task.getId(), "foo");
    // then the task listener was able to access the bpmn model instance and set a variable
    String variableValue = (String) rule.getRuntimeService().getVariable(processInstance.getId(), AccessModelInstanceTaskListener.VARIABLE_NAME);
    Assert.assertEquals("newUserTask", variableValue);
}
Also used : UserTask(org.camunda.bpm.model.bpmn.instance.UserTask) DelegateTask(org.camunda.bpm.engine.delegate.DelegateTask) Task(org.camunda.bpm.engine.task.Task) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Aggregations

UserTask (org.camunda.bpm.model.bpmn.instance.UserTask)22 Test (org.junit.Test)18 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)12 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)12 Task (org.camunda.bpm.engine.task.Task)12 DelegateTask (org.camunda.bpm.engine.delegate.DelegateTask)3 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)3 ResourceRole (org.camunda.bpm.model.bpmn.instance.ResourceRole)3 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)2 Definitions (org.camunda.bpm.model.bpmn.instance.Definitions)2 HumanPerformer (org.camunda.bpm.model.bpmn.instance.HumanPerformer)2 Process (org.camunda.bpm.model.bpmn.instance.Process)2 StartEvent (org.camunda.bpm.model.bpmn.instance.StartEvent)2 CamundaTaskListener (org.camunda.bpm.model.bpmn.instance.camunda.CamundaTaskListener)2 ArrayList (java.util.ArrayList)1 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)1 Association (org.camunda.bpm.model.bpmn.instance.Association)1 BaseElement (org.camunda.bpm.model.bpmn.instance.BaseElement)1 BoundaryEvent (org.camunda.bpm.model.bpmn.instance.BoundaryEvent)1 Performer (org.camunda.bpm.model.bpmn.instance.Performer)1