@Test public void test_getUserByName_nullNotFound_anonymous() { when(mockUserAccessor.getUser(null)).thenReturn(null); User result = classUnderTest.getUserByName(null); assertThat(result.getFullName(), is(new AnonymousUser().getFullName())); }
@Test public void test_getRemoteUser_success() { when(mockUserManager.getRemoteUsername()).thenReturn("someUser"); when(mockUserAccessor.getUser("someUser")).thenReturn(new DefaultUser("someUser")); final User remoteUser = classUnderTest.getRemoteUser(); assertThat(remoteUser.getName(), is("someUser")); }