fix(hardcover): use injected restclient with expected timeouts (#2320)

This commit is contained in:
James Ward
2026-08-12 04:05:29 -04:00
committed by GitHub
parent 41fa0c107a
commit 9d15192c18
4 changed files with 20 additions and 19 deletions
@@ -6,10 +6,10 @@ import org.booklore.model.entity.BookMetadataEntity;
import org.booklore.repository.BookRepository;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentMatchers;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
@@ -48,6 +48,7 @@ class HardcoverSyncServiceTest {
@Mock
private RestClient.ResponseSpec responseSpec;
@InjectMocks
private HardcoverSyncService service;
private BookEntity testBook;
@@ -60,12 +61,7 @@ class HardcoverSyncServiceTest {
@BeforeEach
void setUp() throws Exception {
// Create service with mocked dependencies
service = new HardcoverSyncService(hardcoverSyncSettingsService, bookRepository);
// Inject our mocked restClient using reflection
Field restClientField = HardcoverSyncService.class.getDeclaredField("restClient");
restClientField.setAccessible(true);
restClientField.set(service, restClient);
service = new HardcoverSyncService(hardcoverSyncSettingsService, bookRepository, restClient);
testBook = new BookEntity();
testBook.setId(TEST_BOOK_ID);
@@ -7,8 +7,10 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.web.client.RestClient;
import java.util.List;
@@ -20,12 +22,15 @@ class HardcoverBookSearchServiceTest {
@Mock
private AppSettingService appSettingService;
@Mock
private RestClient restClient;
@InjectMocks
private HardcoverBookSearchService searchService;
@BeforeEach
void setUp() {
MockitoAnnotations.openMocks(this);
searchService = new HardcoverBookSearchService(appSettingService);
}
private void setupAppSettingsWithToken(String token) {