Fix tests
This commit is contained in:
+4
-2
@@ -81,7 +81,8 @@ class BookMarkServiceTest {
|
|||||||
CreateBookMarkRequest request = new CreateBookMarkRequest(bookId, "new-cfi", "New Bookmark");
|
CreateBookMarkRequest request = new CreateBookMarkRequest(bookId, "new-cfi", "New Bookmark");
|
||||||
|
|
||||||
when(authenticationService.getAuthenticatedUser()).thenReturn(userDto);
|
when(authenticationService.getAuthenticatedUser()).thenReturn(userDto);
|
||||||
when(userRepository.getReferenceById(userId)).thenReturn(userEntity);
|
when(bookMarkRepository.existsByCfiAndBookIdAndUserId("new-cfi", bookId, userId)).thenReturn(false);
|
||||||
|
when(userRepository.findById(userId)).thenReturn(Optional.of(userEntity));
|
||||||
when(bookRepository.findById(bookId)).thenReturn(Optional.of(bookEntity));
|
when(bookRepository.findById(bookId)).thenReturn(Optional.of(bookEntity));
|
||||||
when(bookMarkRepository.save(any(BookMarkEntity.class))).thenReturn(bookmarkEntity);
|
when(bookMarkRepository.save(any(BookMarkEntity.class))).thenReturn(bookmarkEntity);
|
||||||
when(mapper.toDto(bookmarkEntity)).thenReturn(bookmarkDto);
|
when(mapper.toDto(bookmarkEntity)).thenReturn(bookmarkDto);
|
||||||
@@ -98,7 +99,8 @@ class BookMarkServiceTest {
|
|||||||
CreateBookMarkRequest request = new CreateBookMarkRequest(bookId, "new-cfi", "New Bookmark");
|
CreateBookMarkRequest request = new CreateBookMarkRequest(bookId, "new-cfi", "New Bookmark");
|
||||||
|
|
||||||
when(authenticationService.getAuthenticatedUser()).thenReturn(userDto);
|
when(authenticationService.getAuthenticatedUser()).thenReturn(userDto);
|
||||||
when(userRepository.getReferenceById(userId)).thenReturn(userEntity);
|
when(bookMarkRepository.existsByCfiAndBookIdAndUserId("new-cfi", bookId, userId)).thenReturn(false);
|
||||||
|
when(userRepository.findById(userId)).thenReturn(Optional.of(userEntity));
|
||||||
when(bookRepository.findById(bookId)).thenReturn(Optional.empty());
|
when(bookRepository.findById(bookId)).thenReturn(Optional.empty());
|
||||||
|
|
||||||
assertThrows(EntityNotFoundException.class, () -> bookMarkService.createBookmark(request));
|
assertThrows(EntityNotFoundException.class, () -> bookMarkService.createBookmark(request));
|
||||||
|
|||||||
Reference in New Issue
Block a user