User extends AbstractAuthzEntity { @Override @Transient @JsonIgnore public User getOwner() { if (application != null) { return application.getOwner(); } return null; }  Application getApplication(); void setApplication(final Application application); Role getRole(); void setRole(final Role role); List<UserIdentity> getIdentities(); void setIdentities(final List<UserIdentity> identities); List<Application> getApplications(); void setApplications(final List<Application> applications); @Override @Transient @JsonIgnore User getOwner();  }
@Test public void testGetOwner() { User user = new User(); Application spy = spy(new Application()); assertNull(user.getOwner()); user.setApplication(spy); user.getOwner(); Mockito.verify(spy).getOwner(); }