@Test public void isPotentialOwnerInDirectAssignmentFalse() { for (User user : availableUsers) { task.getPotentialOwners().remove(user); for (Group group : availableGroups) { user.getGroups().add(group); assertThat(isPotentialOwner(task, user)).isTrue(); user.getGroups().remove(group); assertThat(isPotentialOwner(task, user)).isFalse(); } } }
public static boolean isPotentialOwner(Task task, User user) { final boolean directlyAssigned = task.getPotentialOwners().stream() .filter(OrganizationalEntity::isUser) .anyMatch(entity -> Objects.equals(entity.getEntityId(), user.getEntityId())); if (directlyAssigned) { return true; } final Set<String> acceptedGroupIds = task.getPotentialOwners().stream() .filter(entity -> !entity.isUser()) .map(OrganizationalEntity::getEntityId).collect(Collectors.toSet()); return user.getGroups().stream() .anyMatch(group -> acceptedGroupIds.contains(group.getEntityId())); }
TaskHelper { public static boolean isPotentialOwner(Task task, User user) { final boolean directlyAssigned = task.getPotentialOwners().stream() .filter(OrganizationalEntity::isUser) .anyMatch(entity -> Objects.equals(entity.getEntityId(), user.getEntityId())); if (directlyAssigned) { return true; } final Set<String> acceptedGroupIds = task.getPotentialOwners().stream() .filter(entity -> !entity.isUser()) .map(OrganizationalEntity::getEntityId).collect(Collectors.toSet()); return user.getGroups().stream() .anyMatch(group -> acceptedGroupIds.contains(group.getEntityId())); } }
TaskHelper { public static boolean isPotentialOwner(Task task, User user) { final boolean directlyAssigned = task.getPotentialOwners().stream() .filter(OrganizationalEntity::isUser) .anyMatch(entity -> Objects.equals(entity.getEntityId(), user.getEntityId())); if (directlyAssigned) { return true; } final Set<String> acceptedGroupIds = task.getPotentialOwners().stream() .filter(entity -> !entity.isUser()) .map(OrganizationalEntity::getEntityId).collect(Collectors.toSet()); return user.getGroups().stream() .anyMatch(group -> acceptedGroupIds.contains(group.getEntityId())); } private  TaskHelper(); }
TaskHelper { public static boolean isPotentialOwner(Task task, User user) { final boolean directlyAssigned = task.getPotentialOwners().stream() .filter(OrganizationalEntity::isUser) .anyMatch(entity -> Objects.equals(entity.getEntityId(), user.getEntityId())); if (directlyAssigned) { return true; } final Set<String> acceptedGroupIds = task.getPotentialOwners().stream() .filter(entity -> !entity.isUser()) .map(OrganizationalEntity::getEntityId).collect(Collectors.toSet()); return user.getGroups().stream() .anyMatch(group -> acceptedGroupIds.contains(group.getEntityId())); } private  TaskHelper(); static boolean isPotentialOwner(Task task, User user); static boolean hasAllLabels(Task task, User user, String labelName); static int countMatchingLabels(Task task, User user, String labelName); static List<Task> extractTasks(TaskOrUser taskOrUser); static List<Task> extractTasks(TaskOrUser taskOrUser, Predicate<Task> predicate); static boolean hasPinnedTasks(TaskOrUser user); }
TaskHelper { public static boolean isPotentialOwner(Task task, User user) { final boolean directlyAssigned = task.getPotentialOwners().stream() .filter(OrganizationalEntity::isUser) .anyMatch(entity -> Objects.equals(entity.getEntityId(), user.getEntityId())); if (directlyAssigned) { return true; } final Set<String> acceptedGroupIds = task.getPotentialOwners().stream() .filter(entity -> !entity.isUser()) .map(OrganizationalEntity::getEntityId).collect(Collectors.toSet()); return user.getGroups().stream() .anyMatch(group -> acceptedGroupIds.contains(group.getEntityId())); } private  TaskHelper(); static boolean isPotentialOwner(Task task, User user); static boolean hasAllLabels(Task task, User user, String labelName); static int countMatchingLabels(Task task, User user, String labelName); static List<Task> extractTasks(TaskOrUser taskOrUser); static List<Task> extractTasks(TaskOrUser taskOrUser, Predicate<Task> predicate); static boolean hasPinnedTasks(TaskOrUser user);  }