### Question:
PermissionManager { public void changeRestrictions(Entity entity, PermissionChanges changes) { for (Group group : changes.getNewlyAddedGroupsAsArray()) { changeGrantsOfGroup(group, changes.getPermission(), entity, false); } for (Group group : changes.getRemovedGroupsAsArray()) { deleteGrantsOfGroup(group, changes.getPermission(), entity); } } 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(dataProvider = "accessChanges") public void testChangeRestriction(PermissionChanges changes) throws Exception { Branch branch = ObjectsFactory.getDefaultBranch(); manager.changeRestrictions(branch, changes); verify(aclManager, times(changes.getRemovedGroups().size())). delete(anyListOf(Sid.class), eq(listFromArray(changes.getPermission())), eq(branch)); verify(aclManager, times(changes.getNewlyAddedGroupsAsArray().length)). restrict(anyListOf(Sid.class), eq(listFromArray(changes.getPermission())), eq(branch)); }
@Test public void testRestrictGrantsOfAnonymousGroup() throws Exception { Branch branch = ObjectsFactory.getDefaultBranch(); PermissionChanges changes = new PermissionChanges(BranchPermission.CLOSE_TOPICS); List<Group> groupList = new ArrayList<>(); groupList.add(AnonymousGroup.ANONYMOUS_GROUP); changes.addNewlyAddedGroups(groupList); manager.changeRestrictions(branch, changes); List<Sid> sids = new ArrayList<>(); sids.add(UserSid.createAnonymous()); verify(aclManager, times(changes.getRemovedGroups().size())). delete(eq(sids), eq(listFromArray(changes.getPermission())), eq(branch)); verify(aclManager, times(changes.getNewlyAddedGroupsAsArray().length)). restrict(eq(sids), eq(listFromArray(changes.getPermission())), eq(branch)); }