mirror of https://github.com/bvn13/imdb-spider.git
implemented test for converting imdb data to json
parent
c8cc887938
commit
d519856dfd
|
@ -29,6 +29,25 @@
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- http://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-core/2.8.6/jackson-core-2.8.6.jar -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-core</artifactId>
|
||||||
|
<version>2.9.7</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- http://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-annotations/2.8.6/jackson-annotations-2.8.6.jar -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-annotations</artifactId>
|
||||||
|
<version>2.9.0</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- http://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-databind/2.8.6/jackson-databind-2.8.6.jar -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
<version>2.9.7</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package ru.bvn13.imdbspider.runner;
|
package ru.bvn13.imdbspider.runner;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import ru.bvn13.imdbspider.ImdbSpider;
|
import ru.bvn13.imdbspider.ImdbSpider;
|
||||||
|
@ -36,4 +38,14 @@ public class MovieSearchTest
|
||||||
assertEquals("The Terminator", movie.getOriginalTitle());
|
assertEquals("The Terminator", movie.getOriginalTitle());
|
||||||
assertEquals(Integer.valueOf(1984), movie.getYear());
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue