refactor(metadata): improve hardcover edition selection (#1800)
Co-authored-by: James Ward <james@notjam.es>
This commit is contained in:
+943
-756
File diff suppressed because it is too large
Load Diff
+11
-38
@@ -28,6 +28,17 @@ class HardcoverBookSearchServiceTest {
|
||||
searchService = new HardcoverBookSearchService(appSettingService);
|
||||
}
|
||||
|
||||
private void setupAppSettingsWithToken(String token) {
|
||||
AppSettings appSettings = new AppSettings();
|
||||
MetadataProviderSettings providerSettings = new MetadataProviderSettings();
|
||||
MetadataProviderSettings.Hardcover hardcover = new MetadataProviderSettings.Hardcover();
|
||||
hardcover.setApiKey(token);
|
||||
providerSettings.setHardcover(hardcover);
|
||||
appSettings.setMetadataProviderSettings(providerSettings);
|
||||
|
||||
when(appSettingService.getAppSettings()).thenReturn(appSettings);
|
||||
}
|
||||
|
||||
@Nested
|
||||
@DisplayName("API Token Validation Tests")
|
||||
class ApiTokenTests {
|
||||
@@ -73,42 +84,4 @@ class HardcoverBookSearchServiceTest {
|
||||
assertThat(results).isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@DisplayName("fetchBookDetails Tests")
|
||||
class FetchBookDetailsTests {
|
||||
|
||||
@Test
|
||||
@DisplayName("Should return null when API token is not set")
|
||||
void fetchBookDetails_noToken_returnsNull() {
|
||||
setupAppSettingsWithToken(null);
|
||||
|
||||
HardcoverBookDetails result = searchService.fetchBookDetails(12345);
|
||||
|
||||
assertThat(result).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Should return null when API token is empty")
|
||||
void fetchBookDetails_emptyToken_returnsNull() {
|
||||
setupAppSettingsWithToken("");
|
||||
|
||||
HardcoverBookDetails result = searchService.fetchBookDetails(12345);
|
||||
|
||||
|
||||
assertThat(result).isNull();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setupAppSettingsWithToken(String token) {
|
||||
AppSettings appSettings = new AppSettings();
|
||||
MetadataProviderSettings providerSettings = new MetadataProviderSettings();
|
||||
MetadataProviderSettings.Hardcover hardcover = new MetadataProviderSettings.Hardcover();
|
||||
hardcover.setApiKey(token);
|
||||
providerSettings.setHardcover(hardcover);
|
||||
appSettings.setMetadataProviderSettings(providerSettings);
|
||||
|
||||
when(appSettingService.getAppSettings()).thenReturn(appSettings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"data": {
|
||||
"books": [
|
||||
{
|
||||
"id": 1106368,
|
||||
"slug": "summary-of-ready-player-one-by-ernest-cline-summary-analysis",
|
||||
"title": "Summary of Ready Player One by Ernest Cline | Summary & Analysis",
|
||||
"subtitle": null,
|
||||
"description": null,
|
||||
"cached_contributors": [
|
||||
{
|
||||
"author": {
|
||||
"id": 518954,
|
||||
"slug": "nosco-publishing",
|
||||
"name": "Nosco Publishing",
|
||||
"image": {}
|
||||
},
|
||||
"contribution": null
|
||||
}
|
||||
],
|
||||
"featured_book_series": null,
|
||||
"rating": 3.0,
|
||||
"ratings_count": 1,
|
||||
"reviews_count": 1,
|
||||
"pages": null,
|
||||
"release_date": null,
|
||||
"release_year": null,
|
||||
"image": null,
|
||||
"cached_tags": {},
|
||||
"editions": [
|
||||
{
|
||||
"id": 31130393,
|
||||
"title": "Summary of Ready Player One by Ernest Cline | Summary & Analysis",
|
||||
"subtitle": null,
|
||||
"cached_contributors": [
|
||||
{
|
||||
"author": {
|
||||
"id": 518954,
|
||||
"slug": "nosco-publishing",
|
||||
"name": "Nosco Publishing",
|
||||
"image": {}
|
||||
},
|
||||
"contribution": null
|
||||
}
|
||||
],
|
||||
"pages": null,
|
||||
"release_date": null,
|
||||
"release_year": null,
|
||||
"image": {
|
||||
"url": "https://assets.hardcover.app/external_data/60277606/5d5a3efaf95d750096907c60852322e49f349fe7.jpeg"
|
||||
},
|
||||
"publisher": null,
|
||||
"isbn_10": null,
|
||||
"isbn_13": null,
|
||||
"language": null,
|
||||
"reading_format_id": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user