Search in sources :

Example 11 with UserTask

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

the class ResourceRolesTest method testGetPerformer.

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

Example 12 with UserTask

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

the class UserTaskImpl method registerType.

public static void registerType(ModelBuilder modelBuilder) {
    ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(UserTask.class, BPMN_ELEMENT_USER_TASK).namespaceUri(BPMN20_NS).extendsType(Task.class).instanceProvider(new ModelTypeInstanceProvider<UserTask>() {

        public UserTask newInstance(ModelTypeInstanceContext instanceContext) {
            return new UserTaskImpl(instanceContext);
        }
    });
    implementationAttribute = typeBuilder.stringAttribute(BPMN_ATTRIBUTE_IMPLEMENTATION).defaultValue("##unspecified").build();
    SequenceBuilder sequenceBuilder = typeBuilder.sequence();
    renderingCollection = sequenceBuilder.elementCollection(Rendering.class).build();
    /**
     * camunda extensions
     */
    camundaAssigneeAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_ASSIGNEE).namespace(CAMUNDA_NS).build();
    camundaCandidateGroupsAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_CANDIDATE_GROUPS).namespace(CAMUNDA_NS).build();
    camundaCandidateUsersAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_CANDIDATE_USERS).namespace(CAMUNDA_NS).build();
    camundaDueDateAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_DUE_DATE).namespace(CAMUNDA_NS).build();
    camundaFollowUpDateAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_FOLLOW_UP_DATE).namespace(CAMUNDA_NS).build();
    camundaFormHandlerClassAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_FORM_HANDLER_CLASS).namespace(CAMUNDA_NS).build();
    camundaFormKeyAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_FORM_KEY).namespace(CAMUNDA_NS).build();
    camundaPriorityAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_PRIORITY).namespace(CAMUNDA_NS).build();
    typeBuilder.build();
}
Also used : UserTask(org.camunda.bpm.model.bpmn.instance.UserTask) Task(org.camunda.bpm.model.bpmn.instance.Task) SequenceBuilder(org.camunda.bpm.model.xml.type.child.SequenceBuilder) UserTask(org.camunda.bpm.model.bpmn.instance.UserTask) ModelElementTypeBuilder(org.camunda.bpm.model.xml.type.ModelElementTypeBuilder) ModelTypeInstanceContext(org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)

Example 13 with UserTask

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

the class MigrationAddSubprocessTest method testConcurrentThreeUserTaskMigration.

@Test
public void testConcurrentThreeUserTaskMigration() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.PARALLEL_GATEWAY_PROCESS).getBuilderForElementById("fork", ParallelGatewayBuilder.class).userTask("userTask3").endEvent().done());
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.PARALLEL_GATEWAY_SUBPROCESS_PROCESS).getBuilderForElementById("fork", ParallelGatewayBuilder.class).userTask("userTask3").endEvent().done());
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask1", "userTask2").mapActivities("userTask2", "userTask3").mapActivities("userTask3", "userTask1").build();
    // when
    testHelper.createProcessInstanceAndMigrate(migrationPlan);
    // then
    testHelper.assertExecutionTreeAfterMigration().hasProcessDefinitionId(targetProcessDefinition.getId()).matches(describeExecutionTree(null).scope().id(testHelper.snapshotBeforeMigration.getProcessInstanceId()).child(null).scope().child("userTask1").concurrent().noScope().up().child("userTask2").concurrent().noScope().up().child("userTask3").concurrent().noScope().done());
    testHelper.assertActivityTreeAfterMigration().hasStructure(describeActivityInstanceTree(targetProcessDefinition.getId()).beginScope("subProcess").activity("userTask1", testHelper.getSingleActivityInstanceBeforeMigration("userTask3").getId()).activity("userTask2", testHelper.getSingleActivityInstanceBeforeMigration("userTask1").getId()).activity("userTask3", testHelper.getSingleActivityInstanceBeforeMigration("userTask2").getId()).done());
    List<Task> migratedTasks = testHelper.snapshotAfterMigration.getTasks();
    assertEquals(3, migratedTasks.size());
    for (Task migratedTask : migratedTasks) {
        assertEquals(targetProcessDefinition.getId(), migratedTask.getProcessDefinitionId());
    }
    // and it is possible to successfully complete the migrated instance
    for (Task migratedTask : migratedTasks) {
        rule.getTaskService().complete(migratedTask.getId());
    }
    testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) UserTask(org.camunda.bpm.model.bpmn.instance.UserTask) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Test(org.junit.Test)

Example 14 with UserTask

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

the class MigrationAddSubprocessTest method testAddTwoScopes.

@Test
public void testAddTwoScopes() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.DOUBLE_SUBPROCESS_PROCESS);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask", "userTask").build();
    // when
    testHelper.createProcessInstanceAndMigrate(migrationPlan);
    // then
    testHelper.assertExecutionTreeAfterMigration().hasProcessDefinitionId(targetProcessDefinition.getId()).matches(describeExecutionTree(null).scope().id(testHelper.snapshotBeforeMigration.getProcessInstanceId()).child(null).scope().child("userTask").scope().done());
    testHelper.assertActivityTreeAfterMigration().hasStructure(describeActivityInstanceTree(targetProcessDefinition.getId()).beginScope("outerSubProcess").beginScope("innerSubProcess").activity("userTask", testHelper.getSingleActivityInstanceBeforeMigration("userTask").getId()).done());
    Task migratedTask = testHelper.snapshotAfterMigration.getTaskForKey("userTask");
    Assert.assertNotNull(migratedTask);
    assertEquals(targetProcessDefinition.getId(), migratedTask.getProcessDefinitionId());
    // and it is possible to successfully complete the migrated instance
    rule.getTaskService().complete(migratedTask.getId());
    testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) UserTask(org.camunda.bpm.model.bpmn.instance.UserTask) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Test(org.junit.Test)

Example 15 with UserTask

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

the class MigrationAddSubprocessTest method testNestedScopesMigration1.

@Test
public void testNestedScopesMigration1() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.SUBPROCESS_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.DOUBLE_SUBPROCESS_PROCESS);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask", "userTask").mapActivities("subProcess", "outerSubProcess").build();
    // when
    testHelper.createProcessInstanceAndMigrate(migrationPlan);
    // then
    testHelper.assertExecutionTreeAfterMigration().hasProcessDefinitionId(targetProcessDefinition.getId()).matches(describeExecutionTree(null).scope().id(testHelper.snapshotBeforeMigration.getProcessInstanceId()).child(null).scope().id(testHelper.getSingleExecutionIdForActivityBeforeMigration("subProcess")).child("userTask").scope().done());
    testHelper.assertActivityTreeAfterMigration().hasStructure(describeActivityInstanceTree(targetProcessDefinition.getId()).beginScope("outerSubProcess", testHelper.getSingleActivityInstanceBeforeMigration("subProcess").getId()).beginScope("innerSubProcess").activity("userTask", testHelper.getSingleActivityInstanceBeforeMigration("userTask").getId()).done());
    Task migratedTask = testHelper.snapshotAfterMigration.getTaskForKey("userTask");
    Assert.assertNotNull(migratedTask);
    assertEquals(targetProcessDefinition.getId(), migratedTask.getProcessDefinitionId());
    // and it is possible to successfully complete the migrated instance
    rule.getTaskService().complete(migratedTask.getId());
    testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) UserTask(org.camunda.bpm.model.bpmn.instance.UserTask) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) 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