diff --git a/runner/pom.xml b/runner/pom.xml index fc6f1a5..859077c 100644 --- a/runner/pom.xml +++ b/runner/pom.xml @@ -29,6 +29,25 @@ compile + + + com.fasterxml.jackson.core + jackson-core + 2.9.7 + + + + com.fasterxml.jackson.core + jackson-annotations + 2.9.0 + + + + com.fasterxml.jackson.core + jackson-databind + 2.9.7 + + junit junit diff --git a/runner/src/test/java/ru/bvn13/imdbspider/runner/MovieSearchTest.java b/runner/src/test/java/ru/bvn13/imdbspider/runner/MovieSearchTest.java index 7ef1db9..5fc38c8 100644 --- a/runner/src/test/java/ru/bvn13/imdbspider/runner/MovieSearchTest.java +++ b/runner/src/test/java/ru/bvn13/imdbspider/runner/MovieSearchTest.java @@ -1,5 +1,7 @@ package ru.bvn13.imdbspider.runner; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.BeforeClass; import org.junit.Test; import ru.bvn13.imdbspider.ImdbSpider; @@ -36,4 +38,14 @@ public class MovieSearchTest assertEquals("The Terminator", movie.getOriginalTitle()); assertEquals(Integer.valueOf(1984), movie.getYear()); } + + @Test + public void testSearchTerminatorReturnsJson() throws ImdbSpiderException, JsonProcessingException { + MovieList result = spider.searchMovieByTitle("Терминатор", 5, EnumSet.of(MovieDataType.ID, MovieDataType.TITLE, MovieDataType.ORIGINAL_TITLE, MovieDataType.YEAR)); + + ObjectMapper mapper = new ObjectMapper(); + String json = mapper.writeValueAsString(result); + //System.out.println("JSON = " + json); + assertEquals("{\"retrievedDataTypes\":[\"ELEMENTS\"],\"id\":null,\"url\":\"https://www.imdb.com/find?ref_=nv_sr_fn&q=%D0%A2%D0%B5%D1%80%D0%BC%D0%B8%D0%BD%D0%B0%D1%82%D0%BE%D1%80&s=tt\",\"movies\":[{\"retrievedDataTypes\":[\"ID\",\"TITLE\",\"ORIGINAL_TITLE\",\"YEAR\"],\"id\":\"0088247\",\"url\":\"https://www.imdb.com/title/tt0088247/?ref_=fn_tt_tt_1\",\"title\":\"Терминатор (1984)\",\"originalTitle\":\"The Terminator\",\"year\":1984,\"akas\":{}}]}", json); + } }