@Test(expected = AssertionError.class) public void testSaveUserReturnsNull() { // GIVEN when(userDao.save(any(User.class))).thenReturn(null); // WHEN userService.save(this.mockUser); }
@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()); }
@Test(expected = AssertionError.class) public void testSaveNull() { userService.save(null); }