Establish snippet testing and add trimmed fragments
Change-Id: I514a71dc715ee4c652099c0c34fbe342543266ae
diff --git a/plugin/src/main/java/de/ids_mannheim/korap/plkexport/Snippet.java b/plugin/src/main/java/de/ids_mannheim/korap/plkexport/Snippet.java
index e941f81..6750948 100644
--- a/plugin/src/main/java/de/ids_mannheim/korap/plkexport/Snippet.java
+++ b/plugin/src/main/java/de/ids_mannheim/korap/plkexport/Snippet.java
@@ -14,11 +14,11 @@
String splitright = split[2];
//(?i) makes the regex case insensitive.
String splitleftr = splitleft.replaceAll("(?i)</?span[^>]*>", "");
- this.setLeft(splitleftr);
+ this.setLeft(splitleftr.trim());
String splitmatchr = splitmatch.replaceAll("(?i)</?span[^>]*>", "");
- this.setMark(splitmatchr);
+ this.setMark(splitmatchr.trim());
String splitrightr = splitright.replaceAll("(?i)</?span[^>]*>", "");
- this.setRight(splitrightr);
+ this.setRight(splitrightr.trim());
}
diff --git a/plugin/src/test/java/de/ids_mannheim/korap/plkexport/SnippetTest.java b/plugin/src/test/java/de/ids_mannheim/korap/plkexport/SnippetTest.java
new file mode 100644
index 0000000..d8d7e18
--- /dev/null
+++ b/plugin/src/test/java/de/ids_mannheim/korap/plkexport/SnippetTest.java
@@ -0,0 +1,23 @@
+package de.ids_mannheim.korap.plkexport;
+
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.fail;
+import org.junit.Test;
+
+import de.ids_mannheim.korap.plkexport.Snippet;
+
+public class SnippetTest {
+
+ @Test
+ public void testSimple () {
+ Snippet s = new Snippet("<span class=\"context-left\">Der </span><span class=\"match\"><mark>Plagegeist</mark></span><span class=\"context-right\"> ging um</span>");
+ assertEquals(s.getLeft(),"Der");
+ assertEquals(s.getRight(),"ging um");
+ assertEquals(s.getMark(),"Plagegeist");
+ };
+};