GroupImpl extends AuthorizableImpl implements Group { @Override public boolean addMember(@NotNull Authorizable authorizable) throws RepositoryException { try { if (isValid(authorizable)) { return getDelegate().addMember(((AuthorizableImpl) authorizable).getDlg()); } else { return false; } } finally { getMgr().autosave(); } } GroupImpl(Group dlg, AutoSaveEnabledManager mgr); @NotNull @Override Iterator<Authorizable> getDeclaredMembers(); @NotNull @Override Iterator<Authorizable> getMembers(); @Override boolean isDeclaredMember(@NotNull Authorizable authorizable); @Override boolean isMember(@NotNull Authorizable authorizable); @Override boolean addMember(@NotNull Authorizable authorizable); @NotNull @Override Set<String> addMembers(@NotNull String... memberIds); @Override boolean removeMember(@NotNull Authorizable authorizable); @NotNull @Override Set<String> removeMembers(@NotNull String... memberIds);  }
@Test public void testAddInvalidMember() throws Exception { assertFalse(group.addMember(getTestUser())); verify(dlg, never()).addMember(getTestUser()); verify(autosaveMgr, times(1)).autosave(); }
@Test public void testAddMember() throws Exception { User u = new UserImpl(getTestUser(), autosaveMgr); assertTrue(group.addMember(u)); verify(dlg, times(1)).addMember(getTestUser()); verify(autosaveMgr, times(1)).autosave(); }