当前位置: 首页>>代码示例>>Java>>正文


Java Task.setAssignee方法代码示例

本文整理汇总了Java中org.camunda.bpm.engine.task.Task.setAssignee方法的典型用法代码示例。如果您正苦于以下问题:Java Task.setAssignee方法的具体用法?Java Task.setAssignee怎么用?Java Task.setAssignee使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.camunda.bpm.engine.task.Task的用法示例。


在下文中一共展示了Task.setAssignee方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testTaskInvolvedUser

import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testTaskInvolvedUser() {
  // given
  runtimeService.startProcessInstanceByKey("oneTaskProcess");
  String taskId = taskService.createTaskQuery().singleResult().getId();
  // if
  identityService.setAuthenticatedUserId("aAssignerId");
  taskService.addCandidateUser(taskId, "aUserId");
  taskService.addCandidateUser(taskId, "bUserId");
  taskService.deleteCandidateUser(taskId, "aUserId");
  taskService.deleteCandidateUser(taskId, "bUserId");
  Task taskAssignee = taskService.newTask("newTask");
  taskAssignee.setAssignee("aUserId");
  taskService.saveTask(taskAssignee);
  // query test
  assertEquals(2, historyService.createHistoricTaskInstanceQuery().taskInvolvedUser("aUserId").count());
  assertEquals(1, historyService.createHistoricTaskInstanceQuery().taskInvolvedUser("bUserId").count());
  assertEquals(0, historyService.createHistoricTaskInstanceQuery().taskInvolvedUser("invalidUserId").count());
  taskService.deleteTask("newTask",true);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:22,代码来源:HistoricTaskInstanceQueryTest.java

示例2: testSaveProcessTaskUpdateWithUpdatePermissionOnTask

import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
public void testSaveProcessTaskUpdateWithUpdatePermissionOnTask() {
  // given
  startProcessInstanceByKey(PROCESS_KEY);
  Task task = selectSingleTask();
  task.setAssignee("demo");

  createGrantAuthorization(TASK, task.getId(), userId, UPDATE);

  // when
  taskService.saveTask(task);

  // then
  task = selectSingleTask();
  assertNotNull(task);
  assertEquals("demo", task.getAssignee());
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:17,代码来源:TaskAuthorizationTest.java

示例3: testSaveProcessTaskUpdateWithTaskAssignPermissionOnTask

import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
public void testSaveProcessTaskUpdateWithTaskAssignPermissionOnTask() {
  // given
  startProcessInstanceByKey(PROCESS_KEY);
  Task task = selectSingleTask();
  task.setAssignee("demo");

  createGrantAuthorization(TASK, task.getId(), userId, TASK_ASSIGN);

  // when
  taskService.saveTask(task);

  // then
  task = selectSingleTask();
  assertNotNull(task);
  assertEquals("demo", task.getAssignee());
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:17,代码来源:TaskAuthorizationTest.java

示例4: testSaveProcessTaskUpdateWithUpdatePermissionOnAnyTask

import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
public void testSaveProcessTaskUpdateWithUpdatePermissionOnAnyTask() {
  // given
  startProcessInstanceByKey(PROCESS_KEY);
  Task task = selectSingleTask();
  task.setAssignee("demo");

  createGrantAuthorization(TASK, ANY, userId, UPDATE);

  // when
  taskService.saveTask(task);

  // then
  task = selectSingleTask();
  assertNotNull(task);
  assertEquals("demo", task.getAssignee());
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:17,代码来源:TaskAuthorizationTest.java

示例5: testSaveProcessTaskUpdateWithTaskAssignPermissionOnProcessDefinition

import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
public void testSaveProcessTaskUpdateWithTaskAssignPermissionOnProcessDefinition() {
  // given
  startProcessInstanceByKey(PROCESS_KEY);
  Task task = selectSingleTask();
  task.setAssignee("demo");

  createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, TASK_ASSIGN);

  // when
  taskService.saveTask(task);

  // then
  task = selectSingleTask();
  assertNotNull(task);
  assertEquals("demo", task.getAssignee());
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:17,代码来源:TaskAuthorizationTest.java

示例6: testAssignSameAssigneeAndOwnerToTask

import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
public void testAssignSameAssigneeAndOwnerToTask() {

    // given
    createGrantAuthorization(Resources.TASK, Authorization.ANY, userId, Permissions.ALL);

    // when
    Task newTask = taskService.newTask();
    newTask.setAssignee("Horst");
    newTask.setOwner("Horst");

    // then
    try {
      taskService.saveTask(newTask);
    } catch (Exception e) {
      fail("Setting same assignee and owner to user should not fail!");
    }

    taskService.deleteTask(newTask.getId(), true);
  }
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:20,代码来源:TaskAuthorizationTest.java

示例7: testPermissionsOnAssignSameAssigneeAndOwnerToTask

import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
public void testPermissionsOnAssignSameAssigneeAndOwnerToTask() {

    try {
      // given
      createGrantAuthorization(Resources.TASK, Authorization.ANY, userId, Permissions.CREATE, Permissions.DELETE, Permissions.READ);
      processEngineConfiguration.setResourceAuthorizationProvider(new MyExtendedPermissionDefaultAuthorizationProvider());

      // when
      Task newTask = taskService.newTask();
      newTask.setAssignee("Horst");
      newTask.setOwner("Horst");
      taskService.saveTask(newTask);

      // then
      Authorization auth = authorizationService.createAuthorizationQuery().userIdIn("Horst").singleResult();
      assertTrue(auth.isPermissionGranted(Permissions.DELETE_HISTORY));

      taskService.deleteTask(newTask.getId(), true);

    } finally {
      processEngineConfiguration.setResourceAuthorizationProvider(new DefaultAuthorizationProvider());
    }


  }
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:26,代码来源:TaskAuthorizationTest.java

示例8: testAssignmentTaskListenerWhenSavingTask

import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
@Test
public void testAssignmentTaskListenerWhenSavingTask() {
  AssignmentTaskListener.reset();

  final BpmnModelInstance process = Bpmn.createExecutableProcess("process")
      .startEvent()
      .userTask("task")
        .camundaTaskListenerClass("assignment", AssignmentTaskListener.class)
      .endEvent()
      .done();

  testRule.deploy(process);
  engineRule.getRuntimeService().startProcessInstanceByKey("process");

  // given
  Task task = engineRule.getTaskService().createTaskQuery().singleResult();

  // when
  task.setAssignee("gonzo");
  engineRule.getTaskService().saveTask(task);

  // then
  assertEquals(1, AssignmentTaskListener.eventCounter);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:25,代码来源:TaskListenerTest.java

示例9: testTaskHadCandidateUser

import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testTaskHadCandidateUser() {
  // given
  runtimeService.startProcessInstanceByKey("oneTaskProcess");
  String taskId = taskService.createTaskQuery().singleResult().getId();
  // if
  identityService.setAuthenticatedUserId("aAssignerId");
  taskService.addCandidateUser(taskId, "aUserId");
  taskService.addCandidateUser(taskId, "bUserId");
  taskService.deleteCandidateUser(taskId, "bUserId");
  Task taskAssignee = taskService.newTask("newTask");
  taskAssignee.setAssignee("aUserId");
  taskService.saveTask(taskAssignee);
  // query test
  assertEquals(1, historyService.createHistoricTaskInstanceQuery().taskHadCandidateUser("aUserId").count());
  assertEquals(1, historyService.createHistoricTaskInstanceQuery().taskHadCandidateUser("bUserId").count());
  assertEquals(0, historyService.createHistoricTaskInstanceQuery().taskHadCandidateUser("invalidUserId").count());
  // delete test
  taskService.deleteTask("newTask",true);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:22,代码来源:HistoricTaskInstanceQueryTest.java

示例10: testStopTask

import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
@Test
@Deployment(resources = "org/camunda/bpm/engine/cdi/test/api/BusinessProcessBeanTest.test.bpmn20.xml")
public void testStopTask() {
  BusinessProcess businessProcess = getBeanInstance(BusinessProcess.class);

  // cannot stop task in absence of an association:
  try {
    businessProcess.stopTask();
    fail();
  } catch (ProcessEngineCdiException e) {
    assertEquals("No task associated. Call businessProcess.startTask() first.", e.getMessage());
  }

  // start the process
  String processInstanceId = businessProcess.startProcessByKey("businessProcessBeanTest", Collections.singletonMap("key", (Object) "value")).getId();
  assertEquals("value", runtimeService.getVariable(processInstanceId, "key"));

  businessProcess.startTask(taskService.createTaskQuery().singleResult().getId());

  // assignee is not set to jonny
  assertNull(taskService.createTaskQuery().taskAssignee("jonny").singleResult());
  Task task = businessProcess.getTask();
  task.setAssignee("jonny");

  // if we stop the task
  businessProcess.stopTask();

  // THEN

  // assignee is not set to jonny
  assertNull(taskService.createTaskQuery().taskAssignee("jonny").singleResult());
  // business process is not associated with task:
  assertFalse(businessProcess.isTaskAssociated());
  assertFalse(businessProcess.isAssociated());
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:36,代码来源:BusinessProcessBeanTest.java

示例11: testShouldAddIdentityLinkForTaskCreationWithAssigneeAndOwner

import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
public void testShouldAddIdentityLinkForTaskCreationWithAssigneeAndOwner() {

    String taskAssigneeId = "Assigneee";
    String taskOwnerId = "Owner";
    // Pre test
    List<HistoricIdentityLinkLog> historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list();
    assertEquals(historicIdentityLinks.size(), 0);

    Task taskAssignee = taskService.newTask(taskAssigneeId);
    taskAssignee.setAssignee(USER_1);
    taskService.saveTask(taskAssignee);

    Task taskOwner = taskService.newTask(taskOwnerId);
    taskOwner.setOwner(OWNER_1);
    taskService.saveTask(taskOwner);

    Task taskEmpty = taskService.newTask();
    taskService.saveTask(taskEmpty);

    // then
    historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list();
    assertEquals(historicIdentityLinks.size(), 2);

    // Basic Query test
    HistoricIdentityLinkLogQuery query = historyService.createHistoricIdentityLinkLogQuery();
    assertEquals(query.type(IdentityLinkType.ASSIGNEE).count(), 1);
    assertEquals(query.userId(USER_1).count(), 1);

    query = historyService.createHistoricIdentityLinkLogQuery();
    assertEquals(query.type(IdentityLinkType.OWNER).count(), 1);
    assertEquals(query.userId(OWNER_1).count(), 1);

    taskService.deleteTask(taskAssigneeId,true);
    taskService.deleteTask(taskOwnerId,true);
    taskService.deleteTask(taskEmpty.getId(), true);
  }
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:37,代码来源:HistoricIdentityLinkLogTest.java

示例12: testShouldAddIdentityLinkByProcessDefinitionAndStandalone

import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testShouldAddIdentityLinkByProcessDefinitionAndStandalone() {

  String taskAssigneeId = "Assigneee";
  // Pre test
  List<HistoricIdentityLinkLog> historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list();
  assertEquals(historicIdentityLinks.size(), 0);

  ProcessInstance processInstance = startProcessInstance(PROCESS_DEFINITION_KEY);
  String taskId = taskService.createTaskQuery().singleResult().getId();

  // given
  Task taskAssignee = taskService.newTask(taskAssigneeId);
  taskAssignee.setAssignee(USER_1);
  taskService.saveTask(taskAssignee);

  // if
  addAndDeleteUserWithAssigner(taskId, IdentityLinkType.ASSIGNEE);

  // then
  historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list();
  assertEquals(historicIdentityLinks.size(), 3);

  // Basic Query test
  HistoricIdentityLinkLogQuery query = historyService.createHistoricIdentityLinkLogQuery();
  assertEquals(query.type(IdentityLinkType.ASSIGNEE).count(), 3);

  query = historyService.createHistoricIdentityLinkLogQuery();
  assertEquals(query.processDefinitionId(processInstance.getProcessDefinitionId()).count(), 2);
  assertEquals(query.processDefinitionKey(PROCESS_DEFINITION_KEY).count(), 2);

  taskService.deleteTask(taskAssigneeId, true);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:34,代码来源:HistoricIdentityLinkLogTest.java

示例13: testSaveCaseTaskUpdate

import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
public void testSaveCaseTaskUpdate() {
  // given
  createCaseInstanceByKey(CASE_KEY);
  Task task = selectSingleTask();
  task.setAssignee("demo");

  // when
  taskService.saveTask(task);

  // then
  task = selectSingleTask();
  assertNotNull(task);
  assertEquals("demo", task.getAssignee());
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:15,代码来源:TaskAuthorizationTest.java

示例14: testStandaloneTaskSetAssigneeOutsideCommandContextSave

import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
public void testStandaloneTaskSetAssigneeOutsideCommandContextSave() {
  // given
  String taskId = "myTask";
  createTask(taskId);
  createGrantAuthorization(TASK, taskId, userId, UPDATE);

  Task task = selectSingleTask();

  task.setAssignee("demo");

  // when
  taskService.saveTask(task);

  // then
  disableAuthorization();
  Authorization authorization = authorizationService
      .createAuthorizationQuery()
      .userIdIn("demo")
      .singleResult();
  enableAuthorization();

  assertNotNull(authorization);
  assertEquals(TASK.resourceType(), authorization.getResourceType());
  assertEquals(taskId, authorization.getResourceId());
  assertTrue(authorization.isPermissionGranted(READ));
  assertTrue(authorization.isPermissionGranted(getDefaultTaskPermissionForUser()));

  deleteTask(taskId, true);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:30,代码来源:TaskAuthorizationTest.java

示例15: testTaskWasAssigned

import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testTaskWasAssigned() {
  // given
  Task taskOne = taskService.newTask("taskOne");
  Task taskTwo = taskService.newTask("taskTwo");
  Task taskThree = taskService.newTask("taskThree");

  // when
  taskOne.setAssignee("aUserId");
  taskService.saveTask(taskOne);

  taskTwo.setAssignee("anotherUserId");
  taskService.saveTask(taskTwo);

  taskService.saveTask(taskThree);

  List<HistoricTaskInstance> list = historyService.createHistoricTaskInstanceQuery().taskAssigned().list();

  // then
  assertEquals(list.size(), 2);

  // cleanup
  taskService.deleteTask("taskOne",true);
  taskService.deleteTask("taskTwo",true);
  taskService.deleteTask("taskThree",true);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:28,代码来源:HistoricTaskInstanceQueryTest.java


注:本文中的org.camunda.bpm.engine.task.Task.setAssignee方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。