refactor(api): use spring objectmapper where possible (#1507)
This commit is contained in:
+2
-1
@@ -3,6 +3,7 @@ package org.booklore.convertor;
|
||||
import org.booklore.model.dto.BookRecommendationLite;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import tools.jackson.databind.ObjectMapper;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -14,7 +15,7 @@ class BookRecommendationIdsListConverterTest {
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
converter = new BookRecommendationIdsListConverter();
|
||||
converter = new BookRecommendationIdsListConverter(new ObjectMapper());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -2,18 +2,18 @@ package org.booklore.convertor;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import tools.jackson.databind.ObjectMapper;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class JpaJsonConverterTest {
|
||||
|
||||
private JpaJsonConverter converter;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
converter = new JpaJsonConverter();
|
||||
converter = new JpaJsonConverter(new ObjectMapper());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.booklore.convertor;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import tools.jackson.databind.ObjectMapper;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -13,7 +14,7 @@ class MapToStringConverterTest {
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
converter = new MapToStringConverter();
|
||||
converter = new MapToStringConverter(new ObjectMapper());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
import tools.jackson.databind.ObjectMapper;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -20,7 +21,7 @@ class VersionServiceTest {
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
service = new VersionService();
|
||||
service = new VersionService(new ObjectMapper());
|
||||
spyService = Mockito.spy(service);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.MockedStatic;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.jaudiotagger.audio.AudioFileIO;
|
||||
import tools.jackson.databind.ObjectMapper;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
@@ -43,7 +44,7 @@ class AudiobookMetadataExtractorTest {
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
extractor = new AudiobookMetadataExtractor(ffprobeService);
|
||||
extractor = new AudiobookMetadataExtractor(new ObjectMapper(), ffprobeService);
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+2
-1
@@ -9,6 +9,7 @@ import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
import org.junit.jupiter.params.provider.NullAndEmptySource;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
import tools.jackson.databind.ObjectMapper;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
@@ -31,7 +32,7 @@ class EpubMetadataExtractorTest {
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
extractor = new EpubMetadataExtractor();
|
||||
extractor = new EpubMetadataExtractor(new ObjectMapper());
|
||||
}
|
||||
|
||||
private File createEpub(String opfContent) throws IOException {
|
||||
|
||||
@@ -15,10 +15,10 @@ import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockedStatic;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import tools.jackson.databind.ObjectMapper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -42,7 +42,6 @@ public class GoodReadsParserTest {
|
||||
|
||||
private MockedStatic<Jsoup> mockJsoup;
|
||||
|
||||
@InjectMocks
|
||||
private GoodReadsParser parser;
|
||||
|
||||
private String exampleSearchJsonFixture;
|
||||
@@ -51,6 +50,12 @@ public class GoodReadsParserTest {
|
||||
|
||||
@BeforeEach
|
||||
void setUp() throws IOException {
|
||||
parser = new GoodReadsParser(
|
||||
httpClient,
|
||||
appSettingService,
|
||||
new ObjectMapper()
|
||||
);
|
||||
|
||||
exampleSearchJsonFixture = readFixture("example-search.json");
|
||||
exampleBookHtmlFixture = readFixture("example-book.html");
|
||||
|
||||
|
||||
+3
-3
@@ -8,15 +8,14 @@ import org.booklore.model.dto.settings.MetadataProviderSettings;
|
||||
import org.booklore.service.appsettings.AppSettingService;
|
||||
import org.jsoup.Connection;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockedStatic;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import tools.jackson.databind.ObjectMapper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -35,7 +34,6 @@ class LubimyCzytacParserTest {
|
||||
|
||||
private MockedStatic<Jsoup> mockJsoup;
|
||||
|
||||
@InjectMocks
|
||||
private LubimyCzytacParser parser;
|
||||
|
||||
private String exampleSearchHtmlFixture;
|
||||
@@ -44,6 +42,8 @@ class LubimyCzytacParserTest {
|
||||
|
||||
@BeforeEach
|
||||
void setUp() throws IOException {
|
||||
parser = new LubimyCzytacParser(appSettingService, new ObjectMapper());
|
||||
|
||||
exampleSearchHtmlFixture = readFixture("example-search.html");
|
||||
exampleBookHtmlFixture = readFixture("example-book.html");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user