Java Code Examples for org.camunda.bpm.engine.task.Task#setTenantId()

The following examples show how to use org.camunda.bpm.engine.task.Task#setTenantId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultiTenancyTaskServiceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testStandaloneTaskCreateWithTenantId() {

    // given a transient task with tenant id
    Task task = taskService.newTask();
    task.setTenantId(tenant1);

    // if
    // it is saved
    taskService.saveTask(task);

    // then
    // when I load it, the tenant id is preserved
    task = taskService.createTaskQuery().taskId(task.getId()).singleResult();
    assertEquals(tenant1, task.getTenantId());

    // Finally, delete task
    deleteTasks(task);
  }
 
Example 2
Source File: MultiTenancyTaskServiceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testStandaloneTaskCannotChangeTenantIdIfNull() {

    // given a persistent task without tenant id
    Task task = taskService.newTask();
    taskService.saveTask(task);
    task = taskService.createTaskQuery().singleResult();

    // if
    // change the tenant id
    task.setTenantId(tenant1);

    // then
    // an exception is thrown on 'save'
    try {
      taskService.saveTask(task);
      fail("Expected an exception");
    }
    catch(ProcessEngineException e) {
      assertTextPresent("ENGINE-03072 Cannot change tenantId of Task", e.getMessage());
    }

    // Finally, delete task
    deleteTasks(task);
  }
 
Example 3
Source File: MultiTenancyTaskServiceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testStandaloneTaskCannotChangeTenantId() {

    // given a persistent task with tenant id
    Task task = taskService.newTask();
    task.setTenantId(tenant1);
    taskService.saveTask(task);
    task = taskService.createTaskQuery().singleResult();

    // if
    // change the tenant id
    task.setTenantId(tenant2);

    // then
    // an exception is thrown on 'save'
    try {
      taskService.saveTask(task);
      fail("Expected an exception");
    }
    catch(ProcessEngineException e) {
      assertTextPresent("ENGINE-03072 Cannot change tenantId of Task", e.getMessage());
    }

    // Finally, delete task
    deleteTasks(task);
  }
 
Example 4
Source File: MultiTenancyTaskServiceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testStandaloneTaskCannotSetDifferentTenantIdOnSubTask() {

    // given a persistent task with a tenant id
    Task task = taskService.newTask();
    task.setTenantId(tenant1);
    taskService.saveTask(task);

    // if
    // I create a subtask with a different tenant id
    Task subTask = taskService.newTask();
    subTask.setParentTaskId(task.getId());
    subTask.setTenantId(tenant2);

    // then an exception is thrown on save
    try {
      taskService.saveTask(subTask);
      fail("Exception expected.");
    }
    catch(ProcessEngineException e) {
      assertTextPresent("ENGINE-03073 Cannot set different tenantId on subtask than on parent Task", e.getMessage());
    }
    // Finally, delete task
    deleteTasks(task);
  }
 
Example 5
Source File: MultiTenancyTaskServiceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testStandaloneTaskCannotSetDifferentTenantIdOnSubTaskWithNull() {

    // given a persistent task without tenant id
    Task task = taskService.newTask();
    taskService.saveTask(task);

    // if
    // I create a subtask with a different tenant id
    Task subTask = taskService.newTask();
    subTask.setParentTaskId(task.getId());
    subTask.setTenantId(tenant1);

    // then an exception is thrown on save
    try {
      taskService.saveTask(subTask);
      fail("Exception expected.");
    }
    catch(ProcessEngineException e) {
      assertTextPresent("ENGINE-03073 Cannot set different tenantId on subtask than on parent Task", e.getMessage());
    }
    // Finally, delete task
    deleteTasks(task);
  }
 
Example 6
Source File: MultiTenancyTaskServiceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testStandaloneTaskPropagateTenantIdToSubTask() {

    // given a persistent task with a tenant id
    Task task = taskService.newTask();
    task.setTenantId(tenant1);
    taskService.saveTask(task);

    // if
    // I create a subtask without tenant id
    Task subTask = taskService.newTask();
    subTask.setParentTaskId(task.getId());
    taskService.saveTask(subTask);

    // then
    // the parent task's tenant id is propagated to the sub task
    subTask = taskService.createTaskQuery().taskId(subTask.getId()).singleResult();
    assertEquals(tenant1, subTask.getTenantId());

    // Finally, delete task
    deleteTasks(subTask, task);
  }
 
Example 7
Source File: MultiTenancyTaskServiceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testStandaloneTaskPropagatesTenantIdToVariableInstance() {
  // given a task with tenant id
  Task task = taskService.newTask();
  task.setTenantId(tenant1);
  taskService.saveTask(task);

  // if we set a variable for the task
  taskService.setVariable(task.getId(), "var", "test");

  // then a variable instance with the same tenant id is created
  VariableInstance variableInstance = runtimeService.createVariableInstanceQuery().singleResult();
  assertThat(variableInstance, is(notNullValue()));
  assertThat(variableInstance.getTenantId(), is(tenant1));

  deleteTasks(task);
}
 
Example 8
Source File: TaskDto.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void updateTask(Task task) {
  task.setName(getName());
  task.setDescription(getDescription());
  task.setPriority(getPriority());
  task.setAssignee(getAssignee());
  task.setOwner(getOwner());

  DelegationState state = null;
  if (getDelegationState() != null) {
    DelegationStateConverter converter = new DelegationStateConverter();
    state = converter.convertQueryParameterToType(getDelegationState());
  }
  task.setDelegationState(state);

  task.setDueDate(getDue());
  task.setFollowUpDate(getFollowUp());
  task.setParentTaskId(getParentTaskId());
  task.setCaseInstanceId(getCaseInstanceId());
  task.setTenantId(getTenantId());
}
 
Example 9
Source File: MultiTenancyTaskQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected String createTaskForTenant(String tenantId) {
  Task task = taskService.newTask();
  if (tenantId != null) {
    task.setTenantId(tenantId);
  }
  taskService.saveTask(task);

  String taskId = task.getId();
  taskIds.add(taskId);

  return taskId;
}
 
Example 10
Source File: MultiTenancyTaskCountByCandidateGroupTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void createTask(String groupId, String tenantId) {
  Task task = taskService.newTask();
  task.setTenantId(tenantId);
  taskService.saveTask(task);

  if (groupId != null) {
    taskService.addCandidateGroup(task.getId(), groupId);
    taskIds.add(task.getId());
  }
}
 
Example 11
Source File: MultiTenancyFilterServiceTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void createTaskForTenant(String tenantId) {
  Task newTask = taskService.newTask();
  newTask.setName("testTask");

  if(tenantId != null) {
    newTask.setTenantId(tenantId);
  }

  taskService.saveTask(newTask);

  taskIds.add(newTask.getId());
}
 
Example 12
Source File: MultiTenancyHistoricDataCmdsTenantCheckTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected String createTaskForTenant(String tenantId) {
  Task task = taskService.newTask();
  task.setTenantId(TENANT_ONE);

  taskService.saveTask(task);
  taskService.complete(task.getId());

  return task.getId();
}
 
Example 13
Source File: MultiTenancyTaskServiceCmdsTenantCheckTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected Task createTaskforTenant() {
  Task newTask = taskService.newTask("newTask");
  newTask.setTenantId(TENANT_ONE);
  taskService.saveTask(newTask);
  
  return newTask;

}
 
Example 14
Source File: TaskCountByCandidateGroupsTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void createTask(String groupId, String tenantId) {
  Task task = taskService.newTask();
  task.setTenantId(tenantId);
  taskService.saveTask(task);

  if (groupId != null) {
    taskService.addCandidateGroup(task.getId(), groupId);
  }

  tasks.add(task.getId());
}
 
Example 15
Source File: FilterTaskQueryTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected void createTasksForOrQueries() {
  Task task1 = taskService.newTask();
  task1.setName("taskForOr");
  task1.setDescription("aTaskDescription");
  task1.setPriority(3);
  taskService.saveTask(task1);

  Task task2 = taskService.newTask();
  task2.setName("taskForOr");
  task2.setDescription("aTaskDescription");
  task2.setAssignee("aTaskAssignee");
  task2.setTenantId("aTenantId");
  taskService.saveTask(task2);

  Task task3 = taskService.newTask();
  task3.setName("taskForOr");
  task3.setOwner("aTaskOwner");
  taskService.saveTask(task3);

  Task task4 = taskService.newTask();
  task4.setName("taskForOr");
  task4.setOwner("aTaskOwner");
  task4.setPriority(3);
  taskService.saveTask(task4);

  Task task5 = taskService.newTask();
  task5.setDescription("aTaskDescription");
  task5.setAssignee("aTaskAssignee");
  taskService.saveTask(task5);

  Task task6 = taskService.newTask();
  task6.setDescription("aTaskDescription");
  task6.setAssignee("aTaskAssignee");
  task6.setTenantId("aTenantId");
  taskService.saveTask(task6);

  Task task7 = taskService.newTask();
  task7.setTenantId("aTenantId");
  task7.setOwner("aTaskOwner");
  task7.setPriority(3);
  task7.setAssignee("aTaskAssignee");
  taskService.saveTask(task7);
}