@Override
public User editDescription(User user, String description) throws UserNotFoundException {
user.setAboutMe(description);
User returnedUser = userRepository.save(user);
if (returnedUser == null) {
throw new UserNotFoundException();
}
return returnedUser;
}
I have this service implementation and the test case is:
@Test
public void shouldEditDescriptionOfTheUser() throws UserNotFoundException{
databuilderService.createAll();
User user = userService.findByEmail("abc@gmail.com");
user.setAboutMe("It's a description about the user");
userService.save(user);
String aboutMe = user.getAboutMe();
LOGGER.info(aboutMe);
Assert.assertNotNull(aboutMe);
}
is this test case covering all the branches ? Should I write another test case for checking the value of user object(null checking) which is a branch in service ?