blob: ebe7f12b2a93c0a8131e3f4452a5ae3663a60d4d [file] [log] [blame]
Akron984fe8f2020-11-25 15:21:37 +01001package de.ids_mannheim.korap.plkexport;
2
3import java.io.IOException;
4
5import static org.junit.Assert.assertEquals;
6import static org.junit.Assert.assertNull;
7import static org.junit.Assert.assertTrue;
8import static org.junit.Assert.assertFalse;
9import static org.junit.Assert.fail;
10import org.junit.Test;
11
12import com.fasterxml.jackson.databind.ObjectMapper;
13import com.fasterxml.jackson.databind.JsonNode;
14import com.fasterxml.jackson.core.JsonProcessingException;
15
Akronede77d72020-11-25 16:32:56 +010016import de.ids_mannheim.korap.plkexport.Match;
Akron984fe8f2020-11-25 15:21:37 +010017
18public class MatchTest {
19
20 private static final ObjectMapper mapper = new ObjectMapper();
21
22 @Test
23 public void testSimple () throws JsonProcessingException, IOException {
24
25 String match = "{\"author\":\"Goethe\","+
26 "\"title\":\"Title1\","+
27 "\"pubDate\":\"20051103\","+
28 "\"textSigle\":\"RTF/G59/34284\","+
29 "\"snippet\":\"<span class=\\\"context-left\\\"></span><span class=\\\"match\\\"><mark>Und dafür, dass</mark><span class=\\\"cutted\\\"></span></span><span class=\\\"context-right\\\"> meine IP öffentlich angezeigt wird. Über die IP kann man auf den Wohnort, den Provider und bei Aufenthalt am Arbeitsplatz auf den Arbeitgeber schließen, über Konto nicht. -- 09:24, 17. Dez. 2011 (CET) Bist Du denn nicht mehr selber Arbeitgeber? -- 09:31<span class=\\\"more\\\"></span></span>\"}";
30
Akronede77d72020-11-25 16:32:56 +010031 Match matchObj = mapper.readValue(match, Match.class);
Akron984fe8f2020-11-25 15:21:37 +010032
33 assertEquals(matchObj.getAuthor(), "Goethe");
34 assertEquals(matchObj.getTitle(), "Title1");
35 assertEquals(matchObj.getPubDate(), "20051103");
36 assertEquals(matchObj.getTextSigle(), "RTF/G59/34284");
37
38 assertTrue(matchObj.getSnippetString().contains("<span class"));
39
Akrone8bef572020-11-25 16:21:17 +010040 assertEquals(matchObj.getSnippet().getMark(),
Akron984fe8f2020-11-25 15:21:37 +010041 "Und dafür, dass");
42
43 };
44
45};