コード例 #1
0
  @Test(expected = AssertionError.class)
  public void testSaveUserReturnsNull() {
    // GIVEN
    when(userDao.save(any(User.class))).thenReturn(null);

    // WHEN
    userService.save(this.mockUser);
  }
コード例 #2
0
  @Test
  public void testSave() {
    // GIVEN
    when(userDao.save(any(User.class))).then(returnsFirstArg());

    // WHEN
    ReflectionTestUtils.setField(mockUser, "email", "*****@*****.**");

    User tmpUser = userService.save(this.mockUser);

    // THEN
    assertEquals(this.mockUser.getEmail(), tmpUser.getEmail());
  }
コード例 #3
0
 @Test(expected = AssertionError.class)
 public void testSaveNull() {
   userService.save(null);
 }