コード例 #1
0
 @Test
 public void shouldFindUserByEmailAndPassword() {
   when(userRepository.findUserByEmailAndPassword(Matchers.anyString(), Matchers.anyString()))
       .thenReturn(new User());
   User user = service.findUserByEmailAndPassword("", "");
   verify(userRepository, times(1))
       .findUserByEmailAndPassword(Matchers.anyString(), Matchers.anyString());
 }
コード例 #2
0
  @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());
  }
コード例 #3
0
  @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());
  }
コード例 #4
0
  @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));
  }
コード例 #5
0
 @Test
 public void shouldGetAllUsersAndTheirConnections() {
   when(userRepository.findAllUsersAndTheirConnections()).thenReturn(new ArrayList<User>());
   service.getAllUsersAndTheirConnections();
   verify(userRepository, times(1)).findAllUsersAndTheirConnections();
 }