Test for empty results
Change-Id: Iae930f82fe628f3ce09e9b13bc5d646981e2e328
diff --git a/plugin/src/test/java/de/ids_mannheim/korap/plkexport/IdsExportServiceTest.java b/plugin/src/test/java/de/ids_mannheim/korap/plkexport/IdsExportServiceTest.java
index 7257201..e2660a1 100644
--- a/plugin/src/test/java/de/ids_mannheim/korap/plkexport/IdsExportServiceTest.java
+++ b/plugin/src/test/java/de/ids_mannheim/korap/plkexport/IdsExportServiceTest.java
@@ -95,7 +95,7 @@
.respond(
response()
.withHeader("Content-Type: application/json; charset=utf-8")
- .withBody("{}")
+ .withBody(getFixture("response_water.json"))
.withStatusCode(200)
);
@@ -141,6 +141,37 @@
};
+ @Test
+ public void testExportWsJsonEmpty () {
+ mockClient.reset().when(
+ request()
+ .withMethod("GET")
+ .withPath("/api/v1.0/search")
+ .withQueryStringParameter("q", "????")
+ )
+ .respond(
+ response()
+ .withHeader("Content-Type: application/json; charset=utf-8")
+ .withBody(getFixture("response_none.json"))
+ .withStatusCode(200)
+ );
+
+ String filenamej = "dateiJson";
+ MultivaluedHashMap<String, String> frmap = new MultivaluedHashMap<String, String>();
+ frmap.add("fname", filenamej);
+ frmap.add("format", "json");
+ frmap.add("q", "????");
+ frmap.add("ql", "poliqarp");
+
+ String message;
+
+ Response responsejson = target("/export").request()
+ .post(Entity.form(frmap));
+
+ assertEquals("Request JSON: Http Response should be 200: ",
+ Status.OK.getStatusCode(), responsejson.getStatus());
+ };
+
@Test
public void testExportWsRTF () {
@@ -148,6 +179,7 @@
request()
.withMethod("GET")
.withPath("/api/v1.0/search")
+ .withQueryStringParameter("q", "Wasser")
)
.respond(
response()
@@ -214,6 +246,38 @@
}
}
+
+ @Test
+ public void testExportWsRTFEmpty () {
+ mockClient.reset().when(
+ request()
+ .withMethod("GET")
+ .withPath("/api/v1.0/search")
+ .withQueryStringParameter("q", "????")
+ )
+ .respond(
+ response()
+ .withHeader("Content-Type: application/json; charset=utf-8")
+ .withBody(getFixture("response_none.json"))
+ .withStatusCode(200)
+ );
+
+ MultivaluedHashMap<String, String> frmap = new MultivaluedHashMap<String, String>();
+ frmap.add("format", "rtf");
+ frmap.add("q", "????");
+ frmap.add("ql", "poliqarp");
+ String filenamer = "dateiRtf";
+ frmap.putSingle("fname", filenamer);
+
+ String message;
+
+ Response responsertf = target("/export").request()
+ .post(Entity.form(frmap));
+ assertEquals("Request RTF: Http Response should be 200: ",
+ Status.OK.getStatusCode(), responsertf.getStatus());
+ }
+
+
// Get fixture from ressources
private String getFixture (String file) {
String filepath = getClass()
diff --git a/plugin/src/test/resources/fixtures/response_none.json b/plugin/src/test/resources/fixtures/response_none.json
new file mode 100644
index 0000000..7299681
--- /dev/null
+++ b/plugin/src/test/resources/fixtures/response_none.json
@@ -0,0 +1,49 @@
+{
+ "@context":"http://korap.ids-mannheim.de/ns/KoralQuery/v0.3/context.jsonld",
+ "meta":{
+ "count":20,
+ "startIndex":0,
+ "timeout":10000,
+ "context":"base/s:s",
+ "fields":[
+ "ID",
+ "UID",
+ "textSigle",
+ "corpusID",
+ "author",
+ "title",
+ "subTitle",
+ "textClass",
+ "pubPlace",
+ "pubDate",
+ "availability",
+ "layerInfos",
+ "docSigle",
+ "corpusSigle"
+ ],
+ "version":"0.59.2",
+ "benchmark":"6.6498159999999995 ms",
+ "totalResults":0,
+ "serialQuery":"tokens:s:????",
+ "itemsPerPage":20
+ },
+ "query":{
+ "@type":"koral:token",
+ "wrap":{
+ "@type":"koral:term",
+ "match":"match:eq",
+ "layer":"orth",
+ "key":"????",
+ "foundry":"opennlp",
+ "rewrites":[
+ {
+ "@type":"koral:rewrite",
+ "src":"Kustvakt",
+ "operation":"operation:injection",
+ "scope":"foundry"
+ }
+ ]
+ }
+ },
+ "matches":[]
+}