UserImpl extends AuthorizableImpl implements User { @NotNull @Override public Impersonation getImpersonation() throws RepositoryException { return new ImpersonationImpl(getDelegate().getImpersonation()); } UserImpl(User dlg, AutoSaveEnabledManager mgr); @Override boolean isAdmin(); @Override boolean isSystemUser(); @NotNull @Override Credentials getCredentials(); @NotNull @Override Impersonation getImpersonation(); @Override void changePassword(@Nullable String pw); @Override void changePassword(@Nullable String pw, @NotNull String oldPw); @Override void disable(@Nullable String msg); @Override boolean isDisabled(); @Nullable @Override String getDisabledReason();  }
@Test public void testGetImpersonation() throws RepositoryException { user.getImpersonation(); verify(dlg, times(2)).getImpersonation(); verify(autosaveMgr, never()).autosave(); }
@Test public void testGetImpersonators() throws Exception { user.getImpersonation().getImpersonators(); verify(impersonationMock, times(1)).getImpersonators(); verify(autosaveMgr, never()).autosave(); }
@Test public void testGrantImpersonation() throws Exception { Principal principal = new PrincipalImpl("any"); user.getImpersonation().grantImpersonation(principal); verify(impersonationMock, times(1)).grantImpersonation(principal); verify(autosaveMgr, times(1)).autosave(); }
@Test public void testRevokeImpersonation() throws Exception { Principal principal = new PrincipalImpl("any"); user.getImpersonation().revokeImpersonation(principal); verify(impersonationMock, times(1)).revokeImpersonation(principal); verify(autosaveMgr, times(1)).autosave(); }
@Test public void testImpersonation() throws Exception { user.getImpersonation().allows(SystemSubject.INSTANCE); verify(impersonationMock, times(1)).allows(SystemSubject.INSTANCE); verify(autosaveMgr, never()).autosave(); }