Source:
<code>public void testUserTasksAsUser() { DocumentModel document = getDocument(); assertNotNull(document); taskService.createTask(session, administrator, document, "Task assigned to user1", <START> Collections.singletonList(user1.getName()), false, null, null, null, null, null); <END> session.save(); List<Task> tasks = taskService.getTaskInstances(document, user1, session); assertNotNull(tasks); assertEquals(1, tasks.size()); Task task = tasks.get(0); assertEquals("Task assigned to user1", task.getName()); List<String> pooledActorIds = task.getActors(); assertEquals(1, pooledActorIds.size()); assertTrue(pooledActorIds.contains(user1.getName())); tasks = taskService.getTaskInstances(document, (NuxeoPrincipal) null, session); assertNotNull(tasks); assertEquals(1, tasks.size()); try (CloseableCoreSession session1 = coreFeature.openCoreSession(user1.getName())) { tasks = taskService.getTaskInstances(document, user1, session1); assertNotNull(tasks); assertEquals(1, tasks.size()); task = tasks.get(0); assertEquals("Task assigned to user1", task.getName()); pooledActorIds = task.getActors(); assertEquals(1, pooledActorIds.size()); assertTrue(pooledActorIds.contains(user1.getName())); tasks = taskService.getTaskInstances(document, (NuxeoPrincipal) null, session1); assertNotNull(tasks); assertEquals(1, tasks.size()); } try (CloseableCoreSession session2 = coreFeature.openCoreSession(user2.getName())) { tasks = taskService.getTaskInstances(document, user1, session2); assertNotNull(tasks); assertEquals(1, tasks.size()); task = tasks.get(0); assertEquals("Task assigned to user1", task.getName()); pooledActorIds = task.getActors(); assertEquals(1, pooledActorIds.size()); assertTrue(pooledActorIds.contains(user1.getName())); tasks = taskService.getTaskInstances(document, (NuxeoPrincipal) null, session2); assertNotNull(tasks); assertEquals(1, tasks.size()); } }</code><technical_language>List.of (master only)</technical_language>

Target:
public void testUserTasksAsUser() { DocumentModel document = getDocument(); assertNotNull(document); taskService.createTask(session, administrator, document, "Task assigned to user1", List.of(user1.getName()), false, null, null, null, null, null); session.save(); List<Task> tasks = taskService.getTaskInstances(document, user1, session); assertNotNull(tasks); assertEquals(1, tasks.size()); Task task = tasks.get(0); assertEquals("Task assigned to user1", task.getName()); List<String> pooledActorIds = task.getActors(); assertEquals(1, pooledActorIds.size()); assertTrue(pooledActorIds.contains(user1.getName())); tasks = taskService.getTaskInstances(document, (NuxeoPrincipal) null, session); assertNotNull(tasks); assertEquals(1, tasks.size()); try (CloseableCoreSession session1 = coreFeature.openCoreSession(user1.getName())) { tasks = taskService.getTaskInstances(document, user1, session1); assertNotNull(tasks); assertEquals(1, tasks.size()); task = tasks.get(0); assertEquals("Task assigned to user1", task.getName()); pooledActorIds = task.getActors(); assertEquals(1, pooledActorIds.size()); assertTrue(pooledActorIds.contains(user1.getName())); tasks = taskService.getTaskInstances(document, (NuxeoPrincipal) null, session1); assertNotNull(tasks); assertEquals(1, tasks.size()); } try (CloseableCoreSession session2 = coreFeature.openCoreSession(user2.getName())) { tasks = taskService.getTaskInstances(document, user1, session2); assertNotNull(tasks); assertEquals(1, tasks.size()); task = tasks.get(0); assertEquals("Task assigned to user1", task.getName()); pooledActorIds = task.getActors(); assertEquals(1, pooledActorIds.size()); assertTrue(pooledActorIds.contains(user1.getName())); tasks = taskService.getTaskInstances(document, (NuxeoPrincipal) null, session2); assertNotNull(tasks); assertEquals(1, tasks.size()); } }