@Test public void shouldDelegateCallToContextService(){ AuthenticationServiceImpl service = new AuthenticationServiceImpl(contextService); User user = new User(); when(contextService.getAuthenticatedUser()).thenReturn(user); User authenticatedUser = service.getAuthenticatedUser(); verify(contextService).getAuthenticatedUser(); assertSame(user,authenticatedUser); }
public User getAuthenticatedUser() { return contextService.getAuthenticatedUser(); }
AuthenticationServiceImpl implements AuthenticationService { public User getAuthenticatedUser() { return contextService.getAuthenticatedUser(); } }
AuthenticationServiceImpl implements AuthenticationService { public User getAuthenticatedUser() { return contextService.getAuthenticatedUser(); } AuthenticationServiceImpl(ContextService contextService); }
AuthenticationServiceImpl implements AuthenticationService { public User getAuthenticatedUser() { return contextService.getAuthenticatedUser(); } AuthenticationServiceImpl(ContextService contextService); User getAuthenticatedUser(); }
AuthenticationServiceImpl implements AuthenticationService { public User getAuthenticatedUser() { return contextService.getAuthenticatedUser(); } AuthenticationServiceImpl(ContextService contextService); User getAuthenticatedUser();  }