@Test
  public void testGetTasksByStatusByProcessIdByTaskName() {
    // One potential owner, should go straight to state Reserved
    String str =
        "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) {processInstanceId = 99 } ), ";
    str +=
        "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet')], }),";
    str += "names = [ new I18NText( 'en-UK', 'This is my task name')] })";
    TaskImpl task = TaskFactory.evalTask(new StringReader(str));
    taskService.addTask(task, new HashMap<String, Object>());

    str =
        "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) {processInstanceId = 100 } ), ";
    str +=
        "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet')], }),";
    str += "names = [ new I18NText( 'en-UK', 'Another name')] })";
    task = TaskFactory.evalTask(new StringReader(str));
    taskService.addTask(task, new HashMap<String, Object>());

    List<Status> statuses = new ArrayList<Status>();
    statuses.add(Status.Reserved);
    List<TaskSummary> tasks =
        taskService.getTasksByStatusByProcessIdByTaskName(
            99L, statuses, "This is my task name", "en-UK");
    assertEquals(1, tasks.size());
  }
 @Test
 public void
     testGetTasksAssignedAsPotentialOwnerWithUserGroupsLangOffsetCountTwoTasksTwoMaxResults() {
   // One potential owner, should go straight to state Reserved
   String str1 = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
   str1 +=
       "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet') ], }),";
   str1 += "names = [ new I18NText( 'en-UK', 'First task')] })";
   String str2 = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
   str2 +=
       "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet') ], }),";
   str2 += "names = [ new I18NText( 'en-UK', 'Second task')] })";
   TaskImpl task1 = TaskFactory.evalTask(new StringReader(str1));
   taskService.addTask(task1, new HashMap<String, Object>());
   TaskImpl task2 = TaskFactory.evalTask(new StringReader(str2));
   taskService.addTask(task2, new HashMap<String, Object>());
   List<String> groupIds = new ArrayList<String>();
   groupIds.add("Crusaders");
   List<TaskSummary> tasks =
       taskService.getTasksAssignedAsPotentialOwner("Bobba Fet", groupIds, "en-UK", 0, 2);
   assertEquals(2, tasks.size());
   // FIXME tasks are returned in random order
   // assertEquals("First task", tasks.get(0).getName());
   // assertEquals("Second task", tasks.get(1).getName());
 }
 @Test
 public void testGetTasksAssignedAsExcludedOwnerWithUserLangOneTask() {
   // One potential owner, should go straight to state Reserved
   String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
   str +=
       "peopleAssignments = (with ( new PeopleAssignments() ) { excludedOwners = [new User('Bobba Fet')], }),";
   str += "names = [ new I18NText( 'en-UK', 'This is my task name')] })";
   TaskImpl task = TaskFactory.evalTask(new StringReader(str));
   taskService.addTask(task, new HashMap<String, Object>());
   List<TaskSummary> tasks = taskService.getTasksAssignedAsExcludedOwner("Bobba Fet", "en-UK");
   assertEquals(1, tasks.size());
 }
 @Test
 public void testGetTasksAssignedByGroupsWithGroupsLangOneTask() {
   // One potential owner, should go straight to state Reserved
   String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
   str +=
       "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new Group('Crusaders')  ], }),";
   str += "names = [ new I18NText( 'en-UK', 'This is my task name')] })";
   TaskImpl task = TaskFactory.evalTask(new StringReader(str));
   taskService.addTask(task, new HashMap<String, Object>());
   List<String> groupIds = new ArrayList<String>();
   groupIds.add("Crusaders");
   List<TaskSummary> tasks = taskService.getTasksAssignedByGroups(groupIds, "en-UK");
   assertEquals(1, tasks.size());
 }
 @Test
 public void testGetTasksAssignedAsPotentialOwnerByStatusWithUserStatusLangOneTaskReserved() {
   // One potential owner, should go straight to state Reserved
   String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
   str +=
       "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet') ], }),";
   str += "names = [ new I18NText( 'en-UK', 'This is my task name')] })";
   TaskImpl task = TaskFactory.evalTask(new StringReader(str));
   taskService.addTask(task, new HashMap<String, Object>());
   List<Status> statuses = new ArrayList<Status>();
   statuses.add(Status.Reserved);
   List<TaskSummary> tasks =
       taskService.getTasksAssignedAsPotentialOwnerByStatus("Bobba Fet", statuses, "en-UK");
   assertEquals(1, tasks.size());
   assertEquals("Bobba Fet", tasks.get(0).getActualOwner().getId());
 }
 @Test
 public void testGetTasksOwnedByExpirationDateWithUserStatusDateOneTaskCompleted() {
   // One potential owner, should go straight to state Reserved
   String str =
       "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { expirationTime = new Date( 10000000 ), } ), ";
   str +=
       "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet')  ], }),";
   str += "names = [ new I18NText( 'en-UK', 'This is my task name')] })";
   TaskImpl task = TaskFactory.evalTask(new StringReader(str));
   taskService.addTask(task, new HashMap<String, Object>());
   List<Status> statuses = new ArrayList<Status>();
   statuses.add(Status.Completed);
   Date date = new Date(10000000);
   List<TaskSummary> tasks =
       taskService.getTasksOwnedByExpirationDate("Bobba Fet", statuses, date);
   assertEquals(0, tasks.size());
 }
 @Ignore("requires fix - returns two tasks, only one should be returned")
 @Test
 public void testGetTasksAssignedAsPotentialOwnerWithUserGroupsLangOneTaskOneGroup() {
   // One potential owner, should go straight to state Reserved
   String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
   str +=
       "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet'), new Group('Crusaders'), ], }),";
   str += "names = [ new I18NText( 'en-UK', 'This is my task name')] })";
   TaskImpl task = TaskFactory.evalTask(new StringReader(str));
   taskService.addTask(task, new HashMap<String, Object>());
   List<String> groupIds = new ArrayList<String>();
   groupIds.add("Crusaders");
   List<TaskSummary> tasks =
       taskService.getTasksAssignedAsPotentialOwner("Bobba Fet", groupIds, "en-UK");
   assertEquals(1, tasks.size());
   assertEquals("Darth Vader", tasks.get(0).getActualOwner().getId());
 }
 @Test
 public void testGetTasksAssignedByGroupsByExpirationDateWithUserStatusDateOneTaskReserved() {
   // One potential owner, should go straight to state Reserved
   String str =
       "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { expirationTime = new Date( 10000000 ), } ), ";
   str +=
       "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new Group('Crusaders')  ], }),";
   str += "names = [ new I18NText( 'en-UK', 'This is my task name')] })";
   TaskImpl task = TaskFactory.evalTask(new StringReader(str));
   taskService.addTask(task, new HashMap<String, Object>());
   List<String> groupIds = new ArrayList<String>();
   groupIds.add("Crusaders");
   Date date = new Date(10000000);
   List<TaskSummary> tasks =
       taskService.getTasksAssignedByGroupsByExpirationDate(groupIds, "en-UK", date);
   assertEquals(1, tasks.size());
   // assertEquals("Bobba Fet", tasks.get(0).getActualOwner().getId());
 }