Fix kobo auto add on bookdrop. (#2116)

This commit is contained in:
Doug Coffin
2026-01-03 14:02:41 -07:00
committed by GitHub
parent ab96eee5bc
commit ae30b3434e
5 changed files with 22 additions and 6 deletions
@@ -6,6 +6,7 @@ import com.adityachandel.booklore.repository.BookdropFileRepository;
import com.adityachandel.booklore.repository.LibraryRepository;
import com.adityachandel.booklore.service.NotificationService;
import com.adityachandel.booklore.service.file.FileMovingHelper;
import com.adityachandel.booklore.service.kobo.KoboAutoShelfService;
import com.adityachandel.booklore.service.monitoring.MonitoringRegistrationService;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;
@@ -40,6 +41,8 @@ class BookDropServiceFinalizeTest {
private AppProperties appProperties;
@Mock
private BookdropNotificationService bookdropNotificationService;
@Mock
private KoboAutoShelfService koboAutoShelfService;
@InjectMocks
private BookDropService bookDropService;
@@ -21,6 +21,7 @@ import com.adityachandel.booklore.service.NotificationService;
import com.adityachandel.booklore.service.file.FileMovingHelper;
import com.adityachandel.booklore.service.fileprocessor.BookFileProcessor;
import com.adityachandel.booklore.service.fileprocessor.BookFileProcessorRegistry;
import com.adityachandel.booklore.service.kobo.KoboAutoShelfService;
import com.adityachandel.booklore.service.metadata.MetadataRefreshService;
import com.adityachandel.booklore.service.monitoring.MonitoringRegistrationService;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -84,6 +85,8 @@ class BookDropServiceTest {
private ObjectMapper objectMapper;
@Mock
private FileMovingHelper fileMovingHelper;
@Mock
private KoboAutoShelfService koboAutoShelfService;
@InjectMocks
private BookDropService bookDropService;
@@ -259,9 +259,11 @@ class KoboAutoShelfServiceTest {
when(shelfRepository.findByUserIdInAndName(List.of(100L), ShelfType.KOBO.getName()))
.thenReturn(List.of(koboShelf1));
try {
koboAutoShelfService.autoAddBookToKoboShelves(1L);
} catch (NullPointerException e) {
}
koboAutoShelfService.autoAddBookToKoboShelves(1L);
verify(bookRepository).save(testBook);
assert testBook.getShelves() != null;
assert testBook.getShelves().contains(koboShelf1);
assert testBook.getShelves().size() == 1;
}
}
}