Fixed the order of annotation keys and values, and added tests.

Change-Id: I1e6a9f27cea2f395bb7c5f27967e5a2d891420ba
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/AnnotationControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/AnnotationControllerTest.java
new file mode 100644
index 0000000..0b37968
--- /dev/null
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/AnnotationControllerTest.java
@@ -0,0 +1,99 @@
+package de.ids_mannheim.korap.web.controller;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Iterator;
+import java.util.Map.Entry;
+
+import javax.ws.rs.core.MediaType;
+
+import org.junit.Test;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.sun.jersey.api.client.ClientResponse;
+
+import de.ids_mannheim.korap.config.SpringJerseyTest;
+import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.utils.JsonUtils;
+
+public class AnnotationControllerTest extends SpringJerseyTest {
+    @Test
+    public void testAnnotationLayers () throws KustvaktException {
+        ClientResponse response = resource().path(API_VERSION)
+                .path("annotation").path("layers").get(ClientResponse.class);
+
+        String entity = response.getEntity(String.class);
+        JsonNode n = JsonUtils.readTree(entity);
+
+        assertEquals(31, n.size());
+        n = n.get(0);
+        assertEquals(1, n.get("id").asInt());
+        assertEquals("opennlp/p", n.get("code").asText());
+        assertEquals("p", n.get("layer").asText());
+        assertEquals("opennlp", n.get("foundry").asText());
+        assertNotNull(n.get("description"));
+    }
+
+    @Test
+    public void testAnnotationFoundry () throws KustvaktException {
+        ClientResponse response =
+                resource().path(API_VERSION).path("annotation")
+                        .path("description").type(MediaType.APPLICATION_JSON)
+                        .entity("{\"codes\":[\"opennlp/*\"], \"language\":\"en\"}")
+                        .post(ClientResponse.class);
+
+        String entity = response.getEntity(String.class);
+        JsonNode n = JsonUtils.readTree(entity);
+
+        n = n.get(0);
+        assertEquals("opennlp", n.get("code").asText());
+        assertEquals("OpenNLP", n.get("description").asText());
+        assertEquals(1, n.get("layers").size());
+
+        n = n.get("layers").get(0);
+        assertEquals("p", n.get("code").asText());
+        assertEquals("Part-of-Speech", n.get("description").asText());
+        assertEquals(52, n.get("keys").size());
+
+        n = n.get("keys").get(0);
+        assertEquals("ADJA", n.get("code").asText());
+        assertEquals("Attributive Adjective", n.get("description").asText());
+        assertTrue(n.get("values") == null);
+    }
+
+    @Test
+    public void testAnnotationValues () throws KustvaktException {
+        ClientResponse response =
+                resource().path(API_VERSION).path("annotation")
+                        .path("description").type(MediaType.APPLICATION_JSON)
+                        .entity("{\"codes\":[\"mate/m\"], \"language\":\"en\"}")
+                        .post(ClientResponse.class);
+
+        String entity = response.getEntity(String.class);
+        JsonNode n = JsonUtils.readTree(entity);
+
+        n = n.get(0);
+        assertEquals("mate", n.get("code").asText());
+        assertEquals("Mate", n.get("description").asText());
+        assertEquals(1, n.get("layers").size());
+
+        n = n.get("layers").get(0);
+        assertEquals("m", n.get("code").asText());
+        assertEquals("Morphology", n.get("description").asText());
+        assertEquals(8, n.get("keys").size());
+
+        n = n.get("keys").get(1);
+        assertEquals("case", n.get("code").asText());
+        assertEquals("Case", n.get("description").asText());
+        assertEquals(5, n.get("values").size());
+
+        n = n.get("values");
+        Iterator<Entry<String, JsonNode>> fields = n.fields();
+        Entry<String, JsonNode> e = fields.next();
+        assertEquals("*", e.getKey());
+        assertEquals("Undefined", e.getValue().asText());
+    }
+
+}
diff --git a/full/src/test/resources/test-config.xml b/full/src/test/resources/test-config.xml
index 7a4b439..26dc607 100644
--- a/full/src/test/resources/test-config.xml
+++ b/full/src/test/resources/test-config.xml
@@ -5,15 +5,15 @@
 	xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
 	xmlns:cache="http://www.springframework.org/schema/cache"
 	xsi:schemaLocation="http://www.springframework.org/schema/beans
-           http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
+           http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/tx
-           http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
+           http://www.springframework.org/schema/tx/spring-tx.xsd
            http://www.springframework.org/schema/aop
-           http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
+           http://www.springframework.org/schema/aop/spring-aop.xsd
            http://www.springframework.org/schema/context
-           http://www.springframework.org/schema/context/spring-context-4.0.xsd
+           http://www.springframework.org/schema/context/spring-context.xsd
            http://www.springframework.org/schema/util
-           http://www.springframework.org/schema/util/spring-util-4.0.xsd">
+           http://www.springframework.org/schema/util/spring-util.xsd">
 
 	<context:component-scan base-package="de.ids_mannheim.korap" />
 	<context:annotation-config />