Fix tests
This commit is contained in:
+1
-1
@@ -81,7 +81,7 @@ public class BookMetadataUpdater {
|
|||||||
log.info("No changes in metadata for book ID {}. Skipping update.", bookId);
|
log.info("No changes in metadata for book ID {}. Skipping update.", bookId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If all fields are locked we must allow unlocking, hasValueChanges will be false
|
// If all fields are locked we must allow unlocking, hasValueChanges will be false
|
||||||
if (metadata.areAllFieldsLocked() && hasValueChanges) {
|
if (metadata.areAllFieldsLocked() && hasValueChanges) {
|
||||||
log.warn("All fields are locked for book ID {}. Skipping update.", bookId);
|
log.warn("All fields are locked for book ID {}. Skipping update.", bookId);
|
||||||
|
|||||||
+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