### Question:
UserUtil { public static Stream<org.kie.server.services.taskassigning.user.system.api.User> filterDuplicates(Collection<org.kie.server.services.taskassigning.user.system.api.User> externalUsers) { if (externalUsers == null) { return Stream.empty(); } else { final Set<String> included = new HashSet<>(); return externalUsers.stream() .filter(Objects::nonNull) .filter(externalUser -> { if (!included.contains(externalUser.getId())) { included.add(externalUser.getId()); return true; } return false; }); } } private  UserUtil(); static User fromExternalUser(org.kie.server.services.taskassigning.user.system.api.User externalUser); static boolean isUser(String userType); static Stream<org.kie.server.services.taskassigning.user.system.api.User> filterDuplicates(Collection<org.kie.server.services.taskassigning.user.system.api.User> externalUsers);  }### Answer:
@Test public void filterDuplicates() { Collection<org.kie.server.services.taskassigning.user.system.api.User> externalUsers = Arrays.asList(mockUser(USER_ID_1), mockUser(USER_ID_2), null, mockUser(USER_ID_1), mockUser(USER_ID_4), null, mockUser(USER_ID_3), mockUser(USER_ID_3)); List<org.kie.server.services.taskassigning.user.system.api.User> result = UserUtil.filterDuplicates(externalUsers).collect(Collectors.toList()); assertEquals(4, result.size()); assertEquals(USER_ID_1, result.get(0).getId()); assertEquals(USER_ID_2, result.get(1).getId()); assertEquals(USER_ID_4, result.get(2).getId()); assertEquals(USER_ID_3, result.get(3).getId()); }
@Test public void filterDuplicatesWhenNull() { assertTrue(UserUtil.filterDuplicates(null).collect(Collectors.toList()).isEmpty()); }