Fix tests

This commit is contained in:
aditya.chandel
2025-12-10 13:08:21 -07:00
parent ef7354c256
commit 503c82fcd7
2 changed files with 5 additions and 3 deletions

View File

@@ -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);

View File

@@ -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));