コード例 #1
0
 public static Status[] getTaskStatuses(String[] data) {
   Status[] result = new Status[data.length];
   for (int i = 0; i < data.length; ++i) {
     if (data[i].toLowerCase().equals(Status.InProgress.toString().toLowerCase())) {
       result[i] = Status.InProgress;
     } else {
       String value = data[i].substring(0, 1).toUpperCase() + data[i].substring(1);
       try {
         result[i] = Status.valueOf(value);
       } catch (Exception e) {
         throw KieRemoteRestOperationException.badRequest(
             "Task status '" + data[i] + "' is not valid.");
       }
     }
   }
   return result;
 }
  @Test
  public void testFindTaskAssignedAsBusinessAdmin() throws Exception {
    assertSuccess(
        client.createContainer(
            "definition-project", new KieContainerResource("definition-project", releaseId)));

    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("stringData", "waiting for signal");
    parameters.put("personData", createPersonInstance("john"));

    Long processInstanceId =
        processClient.startProcess("definition-project", "definition-project.usertask", parameters);

    try {

      List<TaskSummary> tasks =
          taskClient.findTasksAssignedAsBusinessAdministrator("Administrator", 0, 10);
      assertNotNull(tasks);
      assertEquals(1, tasks.size());

      TaskSummary taskInstance = tasks.get(0);
      assertNotNull(taskInstance);
      assertEquals("First task", taskInstance.getName());
      assertEquals("", taskInstance.getDescription());
      assertEquals("Reserved", taskInstance.getStatus());
      assertEquals(0, taskInstance.getPriority().intValue());
      assertEquals("yoda", taskInstance.getActualOwner());
      assertEquals("yoda", taskInstance.getCreatedBy());
      assertEquals("definition-project.usertask", taskInstance.getProcessId());
      assertEquals("definition-project", taskInstance.getContainerId());
      assertEquals(-1, taskInstance.getParentId().longValue());
      assertEquals(processInstanceId, taskInstance.getProcessInstanceId());

      List<String> status = new ArrayList<String>();
      status.add(Status.InProgress.toString());

      tasks = taskClient.findTasksAssignedAsBusinessAdministrator("Administrator", status, 0, 10);
      assertNotNull(tasks);
      assertEquals(0, tasks.size());

    } finally {
      processClient.abortProcessInstance("definition-project", processInstanceId);
    }
  }