Implemented pipe extension in the search API.
Change-Id: If2a486185a7d16a27b7b46d35d85b7d5f27b66cd
diff --git a/lite/Changes b/lite/Changes
index 0402601..d6991e0 100644
--- a/lite/Changes
+++ b/lite/Changes
@@ -1,3 +1,7 @@
+# version 0.62.3
+03/12/2019
+ - Implemented pipe extension in the search API (margaretha)
+
# version 0.62.2
13/11/2019
- Added tests for issue #43 (margaretha)
diff --git a/lite/pom.xml b/lite/pom.xml
index c2f72f0..f06e3d1 100644
--- a/lite/pom.xml
+++ b/lite/pom.xml
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.ids_mannheim.korap</groupId>
<artifactId>Kustvakt-lite</artifactId>
- <version>0.62.2</version>
+ <version>0.62.3</version>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -137,7 +137,7 @@
<dependency>
<groupId>de.ids_mannheim.korap</groupId>
<artifactId>Kustvakt-core</artifactId>
- <version>[0.62.2,)</version>
+ <version>[0.62.3,)</version>
</dependency>
<!-- Jersey test framework -->
<dependency>
diff --git a/lite/src/test/java/de/ids_mannheim/korap/config/LiteJerseyTest.java b/lite/src/test/java/de/ids_mannheim/korap/config/LiteJerseyTest.java
index 99b2703..e6536f5 100644
--- a/lite/src/test/java/de/ids_mannheim/korap/config/LiteJerseyTest.java
+++ b/lite/src/test/java/de/ids_mannheim/korap/config/LiteJerseyTest.java
@@ -30,6 +30,7 @@
public static String[] classPackages =
new String[] { "de.ids_mannheim.korap.web",
+ "de.ids_mannheim.korap.test",
"com.fasterxml.jackson.jaxrs.json"};
@Override
diff --git a/lite/src/test/java/de/ids_mannheim/korap/web/service/LiteSearchPipeTest.java b/lite/src/test/java/de/ids_mannheim/korap/web/service/LiteSearchPipeTest.java
new file mode 100644
index 0000000..5e8d77f
--- /dev/null
+++ b/lite/src/test/java/de/ids_mannheim/korap/web/service/LiteSearchPipeTest.java
@@ -0,0 +1,65 @@
+package de.ids_mannheim.korap.web.service;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.sun.jersey.api.client.ClientResponse;
+
+import de.ids_mannheim.korap.config.KustvaktConfiguration;
+import de.ids_mannheim.korap.config.LiteJerseyTest;
+import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.utils.JsonUtils;
+
+public class LiteSearchPipeTest extends LiteJerseyTest {
+
+ @Autowired
+ private KustvaktConfiguration config;
+
+ private void setTestPipes () throws IOException {
+ String filename = "test-pipes";
+ File f = new File(filename);
+ if (f.exists()) {
+ f.delete();
+ }
+ f.createNewFile();
+ OutputStreamWriter writer =
+ new OutputStreamWriter(new FileOutputStream(f));
+ writer.append("glemm\t");
+ writer.append(resource().getURI().toString());
+ writer.append(API_VERSION);
+ writer.append("/test/glemm");
+ writer.flush();
+ writer.close();
+
+ config.readPipesFile(filename);
+ }
+
+ @Test
+ public void testSearchWithPipes () throws IOException, KustvaktException {
+ setTestPipes();
+ ClientResponse response = resource().path(API_VERSION).path("search")
+ .queryParam("q", "[orth=der]").queryParam("ql", "poliqarp")
+ .queryParam("pipes", "glemm").get(ClientResponse.class);
+
+ String entity = response.getEntity(String.class);
+ JsonNode node = JsonUtils.readTree(entity);
+ assertEquals(3, node.at("/query/wrap/key").size());
+ node = node.at("/query/wrap/rewrites");
+ assertEquals(2, node.size());
+ assertEquals("Glemm", node.at("/0/src").asText());
+ assertEquals("operation:override", node.at("/0/operation").asText());
+ assertEquals("key", node.at("/0/scope").asText());
+
+ assertEquals("Kustvakt", node.at("/1/src").asText());
+ assertEquals("operation:injection", node.at("/1/operation").asText());
+ assertEquals("foundry", node.at("/1/scope").asText());
+ }
+}