mirror of
https://github.com/booklore-app/booklore.git
synced 2025-12-23 22:28:11 -05:00
Fix tests
This commit is contained in:
@@ -81,7 +81,7 @@ public class BookMetadataUpdater {
|
||||
log.info("No changes in metadata for book ID {}. Skipping update.", bookId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// If all fields are locked we must allow unlocking, hasValueChanges will be false
|
||||
if (metadata.areAllFieldsLocked() && hasValueChanges) {
|
||||
log.warn("All fields are locked for book ID {}. Skipping update.", bookId);
|
||||
|
||||
@@ -81,7 +81,8 @@ class BookMarkServiceTest {
|
||||
CreateBookMarkRequest request = new CreateBookMarkRequest(bookId, "new-cfi", "New Bookmark");
|
||||
|
||||
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(bookMarkRepository.save(any(BookMarkEntity.class))).thenReturn(bookmarkEntity);
|
||||
when(mapper.toDto(bookmarkEntity)).thenReturn(bookmarkDto);
|
||||
@@ -98,7 +99,8 @@ class BookMarkServiceTest {
|
||||
CreateBookMarkRequest request = new CreateBookMarkRequest(bookId, "new-cfi", "New Bookmark");
|
||||
|
||||
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());
|
||||
|
||||
assertThrows(EntityNotFoundException.class, () -> bookMarkService.createBookmark(request));
|
||||
|
||||
Reference in New Issue
Block a user