### Question:
PermissionManager { public List<Group> getGroupsByIds(List<Long> groupIds) { if (groupIds.isEmpty()) { return Collections.emptyList(); } else { List<Group> groups = groupDao.getGroupsByIds(groupIds); if (groupIds.contains(0L)) { groups.add(AnonymousGroup.ANONYMOUS_GROUP); } return groups; } } PermissionManager(@Nonnull AclManager aclManager, @Nonnull GroupDao groupDao,
                             @Nonnull AclUtil aclUtil, @Nonnull PluginPermissionManager pluginPermissionManager); void changeGrants(Entity entity, PermissionChanges changes); void changeRestrictions(Entity entity, PermissionChanges changes); GroupsPermissions getPermissionsMapFor(Branch branch); JtalksPermission findBranchPermissionByMask(int mask); GroupsPermissions getPermissionsMapFor(Component component); GroupsPermissions getPermissionsMapFor(List<Group> groups); GroupsPermissions getPermissionsMapFor(List<JtalksPermission> permissions, Entity entity); List<Group> getAllGroupsWithoutExcluded(List<Group> excludedGroupsList, JtalksPermission permission); List<Group> getGroupsByIds(List<Long> groupIds);  }### Answer:
@Test public void getGroupsByIdsShouldReturnAllGroupsWhichIdIsSpecified() { List<Group> groups = Arrays.asList(new Group("group1"), new Group("group2")); List<Long> ids = Arrays.asList(1L, 2L); when(groupDao.getGroupsByIds(ids)).thenReturn(groups); List<Group> result = manager.getGroupsByIds(ids); assertEquals(result, groups); }
@Test public void getGroupsByIdsShouldReturnEmptyListWhenListOfIdsIsEmpty() { List<Group> result = manager.getGroupsByIds(Collections.EMPTY_LIST); assertTrue(result.isEmpty()); }
@Test public void getGroupsByIdsShouldReturnListWithAnonymousGroupWhenListOfIdsContainsZeroValue() { List<Group> groups = new ArrayList<>(Arrays.asList(new Group("group1"))); List<Long> ids = Arrays.asList(0L, 1L); when(groupDao.getGroupsByIds(ids)).thenReturn(groups); List<Group> result = manager.getGroupsByIds(ids); assertTrue(result.contains(AnonymousGroup.ANONYMOUS_GROUP)); }