| Akron | 984fe8f | 2020-11-25 15:21:37 +0100 | [diff] [blame] | 1 | package de.ids_mannheim.korap.plkexport; |
| 2 | |
| 3 | import java.io.IOException; |
| 4 | |
| 5 | import static org.junit.Assert.assertEquals; |
| 6 | import static org.junit.Assert.assertNull; |
| 7 | import static org.junit.Assert.assertTrue; |
| 8 | import static org.junit.Assert.assertFalse; |
| 9 | import static org.junit.Assert.fail; |
| 10 | import org.junit.Test; |
| 11 | |
| 12 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 13 | import com.fasterxml.jackson.databind.JsonNode; |
| 14 | import com.fasterxml.jackson.core.JsonProcessingException; |
| 15 | |
| Akron | ede77d7 | 2020-11-25 16:32:56 +0100 | [diff] [blame] | 16 | import de.ids_mannheim.korap.plkexport.Match; |
| Akron | 984fe8f | 2020-11-25 15:21:37 +0100 | [diff] [blame] | 17 | |
| 18 | public 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 | |
| Akron | ede77d7 | 2020-11-25 16:32:56 +0100 | [diff] [blame] | 31 | Match matchObj = mapper.readValue(match, Match.class); |
| Akron | 984fe8f | 2020-11-25 15:21:37 +0100 | [diff] [blame] | 32 | |
| 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 | |
| Akron | e8bef57 | 2020-11-25 16:21:17 +0100 | [diff] [blame] | 40 | assertEquals(matchObj.getSnippet().getMark(), |
| Akron | 984fe8f | 2020-11-25 15:21:37 +0100 | [diff] [blame] | 41 | "Und dafür, dass"); |
| 42 | |
| 43 | }; |
| 44 | |
| 45 | }; |