ClearMembershipAction extends AbstractAuthorizableAction { @Override public void onRemove(@NotNull Authorizable authorizable, @NotNull Root root, @NotNull NamePathMapper namePathMapper) throws RepositoryException { clearMembership(authorizable); }  @Override void onRemove(@NotNull Authorizable authorizable, @NotNull Root root, @NotNull NamePathMapper namePathMapper);  }
@Test public void testOnRemoveUserNoMembership() throws Exception { when(user.declaredMemberOf()).thenReturn(Collections.emptyIterator()); action.onRemove(user, root, NamePathMapper.DEFAULT); }
@Test public void testOnRemoveGroupNoMembership() throws Exception { action.onRemove(gr, root, NamePathMapper.DEFAULT); }
@Test public void testOnRemoveUserWithMembership() throws Exception { when(user.declaredMemberOf()).thenReturn(Iterators.singletonIterator(gr)); action.onRemove(user, root, NamePathMapper.DEFAULT); assertTrue(gr.removed.contains(user)); }
@Test public void testOnRemoveGroupWithMembership() throws Exception { Group memberGroup = Mockito.mock(Group.class); when(memberGroup.declaredMemberOf()).thenReturn(Iterators.singletonIterator(gr)); action.onRemove(memberGroup, root, NamePathMapper.DEFAULT); assertTrue(gr.removed.contains(memberGroup)); }