use of com.ncedu.fooddelivery.api.v1.errors.notfound.NotFoundEx in project 2021-msk-food-delivery by netcracker-edu.
the class UserServiceTest method getUserDTOByIdNotFound.
@Test
public void getUserDTOByIdNotFound() {
Long userId = 0L;
when(userRepoMock.findById(userId)).thenReturn(Optional.empty());
Exception exception = assertThrows(NotFoundEx.class, () -> {
userService.getUserDTOById(userId);
});
String resultMessage = exception.getMessage();
String perfectMessage = new NotFoundEx(userId.toString()).getMessage();
assertEquals(perfectMessage, resultMessage);
verify(userRepoMock, times(1)).findById(userId);
}
use of com.ncedu.fooddelivery.api.v1.errors.notfound.NotFoundEx in project 2021-msk-food-delivery by netcracker-edu.
the class UserServiceTest method getUserByIdNotFound.
@Test
public void getUserByIdNotFound() {
Long userId = 0L;
when(userRepoMock.findById(userId)).thenReturn(Optional.empty());
Exception exception = assertThrows(NotFoundEx.class, () -> {
userService.getUserById(userId);
});
String resultMessage = exception.getMessage();
String perfectMessage = new NotFoundEx(userId.toString()).getMessage();
assertEquals(perfectMessage, resultMessage);
verify(userRepoMock, times(1)).findById(userId);
}
Aggregations