@Test public void shouldNotGetAuthenticatedUserProfile() { when(authenticatedUserService.getAuthenticatedUser()).thenReturn(null); when(userRepository.findOne(Matchers.anyInt())).thenReturn(new User()); service.getAuthenticatedUserProfile(); verify(authenticatedUserService, times(1)).getAuthenticatedUser(); verify(userRepository, times(0)).findOne(Matchers.anyInt()); }
@Test public void shouldGetAuthenticatedUserProfile() { User user = new User(); user.setId(0); AuthenticatedUser authUser = new AuthenticatedUser(user); when(authenticatedUserService.getAuthenticatedUser()).thenReturn(authUser); when(userRepository.findOne(Matchers.anyInt())).thenReturn(new User()); service.getAuthenticatedUserProfile(); verify(authenticatedUserService, times(1)).getAuthenticatedUser(); verify(userRepository, times(1)).findOne(Matchers.anyInt()); }
@Test public void shouldGetAllConnections() { User user = new User(); user.setId(0); AuthenticatedUser authUser = new AuthenticatedUser(user); when(authenticatedUserService.getAuthenticatedUser()).thenReturn(authUser); when(userRepository.findAllConnectedUsers(Matchers.any(User.class))) .thenReturn(new ArrayList<User>()); service.getAllConnections(); verify(authenticatedUserService, times(1)).getAuthenticatedUser(); verify(userRepository, times(1)).findAllConnectedUsers(Matchers.any(User.class)); }