UserIdentity extends AbstractAuthzEntity { @Override @Transient @JsonIgnore public User getOwner() { if (user != null) { return user.getOwner(); } return null; }  User getUser(); void setUser(final User user); String getRemoteId(); void setRemoteId(final String remoteId); Map<String, String> getClaims(); void setClaims(final Map<String, String> claims); AuthenticatorType getType(); void setType(final AuthenticatorType authType); List<OAuthToken> getTokens(); void setTokens(final List<OAuthToken> tokens); String getSalt(); void setSalt(final String salt); String getPassword(); void setPassword(final String password); @Override @Transient @JsonIgnore User getOwner();  }
@Test public void testGetOwner() { UserIdentity identity = new UserIdentity(); User spy = spy(new User()); assertNull(identity.getOwner()); identity.setUser(spy); identity.getOwner(); Mockito.verify(spy).getOwner(); }