Implemented publish VC task.
Change-Id: I87ef9042d77036b3640aa2687377d94a99ddb9f5
diff --git a/full/src/test/java/de/ids_mannheim/korap/dao/VirtualCorpusAccessDaoTest.java b/full/src/test/java/de/ids_mannheim/korap/dao/VirtualCorpusAccessDaoTest.java
new file mode 100644
index 0000000..3d538af
--- /dev/null
+++ b/full/src/test/java/de/ids_mannheim/korap/dao/VirtualCorpusAccessDaoTest.java
@@ -0,0 +1,40 @@
+package de.ids_mannheim.korap.dao;
+
+import static org.junit.Assert.*;
+
+import java.util.List;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import de.ids_mannheim.korap.constant.VirtualCorpusAccessStatus;
+import de.ids_mannheim.korap.entity.UserGroup;
+import de.ids_mannheim.korap.entity.VirtualCorpusAccess;
+import de.ids_mannheim.korap.exceptions.KustvaktException;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("classpath:test-config.xml")
+public class VirtualCorpusAccessDaoTest {
+
+ @Autowired
+ private VirtualCorpusAccessDao dao;
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Test
+ public void getAccessByVC () throws KustvaktException {
+ List<VirtualCorpusAccess> vcaList = dao.retrieveAccessByVC(2);
+ VirtualCorpusAccess access = vcaList.get(0);
+ assertEquals(VirtualCorpusAccessStatus.ACTIVE, access.getStatus());
+ assertEquals("dory", access.getCreatedBy());
+
+ UserGroup group = access.getUserGroup();
+ assertEquals(2, group.getId());
+ }
+}
diff --git a/full/src/test/java/de/ids_mannheim/korap/dao/VirtualCorpusDaoTest.java b/full/src/test/java/de/ids_mannheim/korap/dao/VirtualCorpusDaoTest.java
index 4ec7314..199753a 100644
--- a/full/src/test/java/de/ids_mannheim/korap/dao/VirtualCorpusDaoTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/dao/VirtualCorpusDaoTest.java
@@ -34,7 +34,7 @@
List<VirtualCorpus> vcList =
dao.retrieveVCByType(VirtualCorpusType.PUBLISHED);
assertEquals(1, vcList.size());
-
+
VirtualCorpus vc = vcList.get(0);
assertEquals(4, vc.getId());
assertEquals("published VC", vc.getName());
diff --git a/full/src/test/java/de/ids_mannheim/korap/misc/DemoUserTest.java b/full/src/test/java/de/ids_mannheim/korap/misc/DemoUserTest.java
index 90ff26d..b3d134c 100644
--- a/full/src/test/java/de/ids_mannheim/korap/misc/DemoUserTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/misc/DemoUserTest.java
@@ -6,7 +6,7 @@
import de.ids_mannheim.korap.config.BeansFactory;
import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.web.service.FastJerseyTest;
+import de.ids_mannheim.korap.web.FastJerseyTest;
/**
* EM: DemoUser is not saved in the new DB
diff --git a/full/src/test/java/de/ids_mannheim/korap/misc/PublicAPITest.java b/full/src/test/java/de/ids_mannheim/korap/misc/PublicAPITest.java
index 784d755..2e895aa 100644
--- a/full/src/test/java/de/ids_mannheim/korap/misc/PublicAPITest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/misc/PublicAPITest.java
@@ -1,6 +1,7 @@
package de.ids_mannheim.korap.misc;
import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.web.service.FastJerseyTest;
+import de.ids_mannheim.korap.web.FastJerseyTest;
+
import org.junit.BeforeClass;
import org.junit.Test;
diff --git a/full/src/test/java/de/ids_mannheim/korap/service/VirtualCorpusServiceTest.java b/full/src/test/java/de/ids_mannheim/korap/service/VirtualCorpusServiceTest.java
new file mode 100644
index 0000000..ed585f1
--- /dev/null
+++ b/full/src/test/java/de/ids_mannheim/korap/service/VirtualCorpusServiceTest.java
@@ -0,0 +1,44 @@
+package de.ids_mannheim.korap.service;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import de.ids_mannheim.korap.constant.VirtualCorpusAccessStatus;
+import de.ids_mannheim.korap.constant.VirtualCorpusType;
+import de.ids_mannheim.korap.dto.UserGroupDto;
+import de.ids_mannheim.korap.entity.VirtualCorpusAccess;
+import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.web.input.VirtualCorpusJson;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("classpath:test-config.xml")
+public class VirtualCorpusServiceTest {
+
+ @Autowired
+ private VirtualCorpusService vcService;
+
+ @Test
+ public void createPublishVC () throws KustvaktException {
+
+ VirtualCorpusJson vc = new VirtualCorpusJson();
+ vc.setCorpusQuery("corpusSigle=GOE");
+ vc.setCreatedBy("VirtualCorpusServiceTest");
+ vc.setName("new published vc");
+ vc.setType(VirtualCorpusType.PUBLISHED);
+ int vcId = vcService.storeVC(vc, "VirtualCorpusServiceTest");
+
+ List<VirtualCorpusAccess> accesses = vcService.retrieveVCAccess(vcId);
+ assertEquals(2, accesses.size());
+ for (VirtualCorpusAccess access : accesses) {
+ assertEquals(VirtualCorpusAccessStatus.HIDDEN, access.getStatus());
+ }
+ }
+
+}
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/FastJerseyTest.java b/full/src/test/java/de/ids_mannheim/korap/web/FastJerseyTest.java
similarity index 92%
rename from full/src/test/java/de/ids_mannheim/korap/web/service/FastJerseyTest.java
rename to full/src/test/java/de/ids_mannheim/korap/web/FastJerseyTest.java
index c1a187e..aa7657a 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/FastJerseyTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/FastJerseyTest.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.web.service;
+package de.ids_mannheim.korap.web;
import java.util.concurrent.ThreadLocalRandom;
@@ -6,6 +6,7 @@
import de.ids_mannheim.korap.config.ContextHolder;
import de.ids_mannheim.korap.config.TestHelper;
+import de.ids_mannheim.korap.web.service.FastJerseyBaseTest;
public abstract class FastJerseyTest extends FastJerseyBaseTest {
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/FilterTest.java b/full/src/test/java/de/ids_mannheim/korap/web/FilterTest.java
similarity index 95%
rename from full/src/test/java/de/ids_mannheim/korap/web/service/full/FilterTest.java
rename to full/src/test/java/de/ids_mannheim/korap/web/FilterTest.java
index 7f3b33b..7dcfa32 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/FilterTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/FilterTest.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.web.service.full;
+package de.ids_mannheim.korap.web;
import static org.junit.Assert.assertEquals;
@@ -16,7 +16,6 @@
import de.ids_mannheim.korap.config.TokenType;
import de.ids_mannheim.korap.config.TestHelper;
import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.web.service.FastJerseyTest;
/** EM: fix tests. new DB does not save users.
* @author hanl
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/OAuth2HandlerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/OAuth2HandlerTest.java
similarity index 98%
rename from full/src/test/java/de/ids_mannheim/korap/web/service/OAuth2HandlerTest.java
rename to full/src/test/java/de/ids_mannheim/korap/web/OAuth2HandlerTest.java
index 9d8fa86..52c266e 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/OAuth2HandlerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/OAuth2HandlerTest.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.web.service;
+package de.ids_mannheim.korap.web;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/SearchKrillTest.java b/full/src/test/java/de/ids_mannheim/korap/web/SearchKrillTest.java
similarity index 98%
rename from full/src/test/java/de/ids_mannheim/korap/web/service/SearchKrillTest.java
rename to full/src/test/java/de/ids_mannheim/korap/web/SearchKrillTest.java
index c08c247..34dd3be 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/SearchKrillTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/SearchKrillTest.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.web.service;
+package de.ids_mannheim.korap.web;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/AuthServiceTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/AuthenticationControllerTest.java
similarity index 96%
rename from full/src/test/java/de/ids_mannheim/korap/web/service/full/AuthServiceTest.java
rename to full/src/test/java/de/ids_mannheim/korap/web/controller/AuthenticationControllerTest.java
index 26bbfa5..79aa8fe 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/AuthServiceTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/AuthenticationControllerTest.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.web.service.full;
+package de.ids_mannheim.korap.web.controller;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -24,7 +24,7 @@
import de.ids_mannheim.korap.user.User;
import de.ids_mannheim.korap.utils.JsonUtils;
import de.ids_mannheim.korap.utils.TimeUtils;
-import de.ids_mannheim.korap.web.service.FastJerseyTest;
+import de.ids_mannheim.korap.web.FastJerseyTest;
/**
* EM: fix tests. New DB does not save users.
@@ -32,7 +32,7 @@
* @date 24/09/2015
*/
@Ignore
-public class AuthServiceTest extends FastJerseyTest {
+public class AuthenticationControllerTest extends FastJerseyTest {
@Autowired
HttpAuthorizationHandler handler;
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/KustvaktCoreRestTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/KustvaktCoreRestTest.java
similarity index 96%
rename from full/src/test/java/de/ids_mannheim/korap/web/service/full/KustvaktCoreRestTest.java
rename to full/src/test/java/de/ids_mannheim/korap/web/controller/KustvaktCoreRestTest.java
index ca0adf2..324ed0e 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/KustvaktCoreRestTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/KustvaktCoreRestTest.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.web.service.full;
+package de.ids_mannheim.korap.web.controller;
import org.junit.Ignore;
import org.junit.Test;
@@ -7,7 +7,7 @@
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.query.serialize.QuerySerializer;
-import de.ids_mannheim.korap.web.service.FastJerseyTest;
+import de.ids_mannheim.korap.web.FastJerseyTest;
/**
* @author hanl
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/MatchInfoServiceTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/MatchInfoControllerTest.java
similarity index 95%
rename from full/src/test/java/de/ids_mannheim/korap/web/service/full/MatchInfoServiceTest.java
rename to full/src/test/java/de/ids_mannheim/korap/web/controller/MatchInfoControllerTest.java
index 6d997b7..11a3193 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/MatchInfoServiceTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/MatchInfoControllerTest.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.web.service.full;
+package de.ids_mannheim.korap.web.controller;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -16,9 +16,9 @@
import de.ids_mannheim.korap.config.TokenType;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.utils.JsonUtils;
-import de.ids_mannheim.korap.web.service.FastJerseyTest;
+import de.ids_mannheim.korap.web.FastJerseyTest;
-public class MatchInfoServiceTest extends FastJerseyTest {
+public class MatchInfoControllerTest extends FastJerseyTest {
@Autowired
HttpAuthorizationHandler handler;
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/OAuth2EndpointTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2EndpointTest.java
similarity index 97%
rename from full/src/test/java/de/ids_mannheim/korap/web/service/full/OAuth2EndpointTest.java
rename to full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2EndpointTest.java
index 9d9f735..4cf05dc 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/OAuth2EndpointTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2EndpointTest.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.web.service.full;
+package de.ids_mannheim.korap.web.controller;
import static org.junit.Assert.assertEquals;
@@ -20,7 +20,7 @@
import de.ids_mannheim.korap.config.TestHelper;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.utils.JsonUtils;
-import de.ids_mannheim.korap.web.service.FastJerseyTest;
+import de.ids_mannheim.korap.web.FastJerseyTest;
/**
* @author hanl
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/PolicyServiceTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/PolicyServiceTest.java
similarity index 98%
rename from full/src/test/java/de/ids_mannheim/korap/web/service/full/PolicyServiceTest.java
rename to full/src/test/java/de/ids_mannheim/korap/web/controller/PolicyServiceTest.java
index 1714ae1..708259a 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/PolicyServiceTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/PolicyServiceTest.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.web.service.full;
+package de.ids_mannheim.korap.web.controller;
import static org.junit.Assert.assertEquals;
@@ -27,7 +27,7 @@
import de.ids_mannheim.korap.security.SecurityPolicy;
import de.ids_mannheim.korap.user.User;
import de.ids_mannheim.korap.user.User.UserFactory;
-import de.ids_mannheim.korap.web.service.FastJerseyTest;
+import de.ids_mannheim.korap.web.FastJerseyTest;
/** Not in the new DB
* @author margaretha
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/QuerySerializationServiceTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/QuerySerializationControllerTest.java
similarity index 97%
rename from full/src/test/java/de/ids_mannheim/korap/web/service/full/QuerySerializationServiceTest.java
rename to full/src/test/java/de/ids_mannheim/korap/web/controller/QuerySerializationControllerTest.java
index ea6ace6..138ca08 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/QuerySerializationServiceTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/QuerySerializationControllerTest.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.web.service.full;
+package de.ids_mannheim.korap.web.controller;
/**
* @author hanl, margaretha
@@ -24,12 +24,12 @@
import de.ids_mannheim.korap.config.TokenType;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.utils.JsonUtils;
-import de.ids_mannheim.korap.web.service.FastJerseyTest;
+import de.ids_mannheim.korap.web.FastJerseyTest;
/* EM: potentially an unused service! */
@Ignore
-public class QuerySerializationServiceTest extends FastJerseyTest {
+public class QuerySerializationControllerTest extends FastJerseyTest {
@Autowired
HttpAuthorizationHandler handler;
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceServiceTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/ResourceControllerTest.java
similarity index 98%
rename from full/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceServiceTest.java
rename to full/src/test/java/de/ids_mannheim/korap/web/controller/ResourceControllerTest.java
index ec5657e..ef47198 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceServiceTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/ResourceControllerTest.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.web.service.full;
+package de.ids_mannheim.korap.web.controller;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
@@ -25,7 +25,7 @@
import de.ids_mannheim.korap.resources.KustvaktResource;
import de.ids_mannheim.korap.user.User;
import de.ids_mannheim.korap.utils.JsonUtils;
-import de.ids_mannheim.korap.web.service.FastJerseyTest;
+import de.ids_mannheim.korap.web.FastJerseyTest;
/**
* @author hanl, margaretha
@@ -34,7 +34,7 @@
*/
@Ignore
@Deprecated
-public class ResourceServiceTest extends FastJerseyTest {
+public class ResourceControllerTest extends FastJerseyTest {
@Autowired
HttpAuthorizationHandler handler;
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceInfoServiceTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/ResourceInfoControllerTest.java
similarity index 97%
rename from full/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceInfoServiceTest.java
rename to full/src/test/java/de/ids_mannheim/korap/web/controller/ResourceInfoControllerTest.java
index c2ac7bb..2a43ec4 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceInfoServiceTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/ResourceInfoControllerTest.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.web.service.full;
+package de.ids_mannheim.korap.web.controller;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
@@ -17,14 +17,14 @@
import de.ids_mannheim.korap.config.TokenType;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.utils.JsonUtils;
-import de.ids_mannheim.korap.web.service.FastJerseyTest;
+import de.ids_mannheim.korap.web.FastJerseyTest;
/**
* @author hanl, margaretha
* @lastUpdate 19/04/2017
* EM: FIX ME: Database restructure
*/
@Ignore
-public class ResourceInfoServiceTest extends FastJerseyTest {
+public class ResourceInfoControllerTest extends FastJerseyTest {
@Autowired
HttpAuthorizationHandler handler;
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceRemoteApiTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/ResourceRemoteApiTest.java
similarity index 78%
rename from full/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceRemoteApiTest.java
rename to full/src/test/java/de/ids_mannheim/korap/web/controller/ResourceRemoteApiTest.java
index 95d7470..4fc436f 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceRemoteApiTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/ResourceRemoteApiTest.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.web.service.full;
+package de.ids_mannheim.korap.web.controller;
import org.junit.Test;
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/SearchServiceTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/SearchControllerTest.java
similarity index 98%
rename from full/src/test/java/de/ids_mannheim/korap/web/service/full/SearchServiceTest.java
rename to full/src/test/java/de/ids_mannheim/korap/web/controller/SearchControllerTest.java
index 0ede615..2f2eb57 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/SearchServiceTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/SearchControllerTest.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.web.service.full;
+package de.ids_mannheim.korap.web.controller;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
@@ -29,14 +29,14 @@
import de.ids_mannheim.korap.security.ac.ResourceFinder;
import de.ids_mannheim.korap.user.User;
import de.ids_mannheim.korap.utils.JsonUtils;
-import de.ids_mannheim.korap.web.service.FastJerseyTest;
+import de.ids_mannheim.korap.web.FastJerseyTest;
/**
* @author hanl, margaretha
* @lastUpdate 30/05/2017
*
*/
-public class SearchServiceTest extends FastJerseyTest {
+public class SearchControllerTest extends FastJerseyTest {
@Autowired
HttpAuthorizationHandler handler;
@@ -150,6 +150,7 @@
response.getStatus());
String entity = response.getEntity(String.class);
JsonNode node = JsonUtils.readTree(entity);
+ System.out.println(entity);
assertNotNull(node);
assertNotEquals(0, node.path("matches").size());
assertEquals("koral:docGroup", node.at("/collection/@type").asText());
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/SearchWithAvailabilityTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/SearchWithAvailabilityTest.java
similarity index 99%
rename from full/src/test/java/de/ids_mannheim/korap/web/service/full/SearchWithAvailabilityTest.java
rename to full/src/test/java/de/ids_mannheim/korap/web/controller/SearchWithAvailabilityTest.java
index dad8f99..73e6880 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/SearchWithAvailabilityTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/SearchWithAvailabilityTest.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.web.service.full;
+package de.ids_mannheim.korap.web.controller;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -17,7 +17,7 @@
import de.ids_mannheim.korap.config.TokenType;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.utils.JsonUtils;
-import de.ids_mannheim.korap.web.service.FastJerseyTest;
+import de.ids_mannheim.korap.web.FastJerseyTest;
public class SearchWithAvailabilityTest extends FastJerseyTest {
@Autowired
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/StatisticsServiceTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/StatisticsControllerTest.java
similarity index 96%
rename from full/src/test/java/de/ids_mannheim/korap/web/service/full/StatisticsServiceTest.java
rename to full/src/test/java/de/ids_mannheim/korap/web/controller/StatisticsControllerTest.java
index 4dd4fb9..eee4016 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/StatisticsServiceTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/StatisticsControllerTest.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.web.service.full;
+package de.ids_mannheim.korap.web.controller;
import java.io.IOException;
@@ -11,14 +11,14 @@
import com.sun.jersey.api.client.ClientResponse;
import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.web.service.FastJerseyTest;
+import de.ids_mannheim.korap.web.FastJerseyTest;
/**
* @author margaretha
* @date 27/09/2017
*
*/
-public class StatisticsServiceTest extends FastJerseyTest {
+public class StatisticsControllerTest extends FastJerseyTest {
private ObjectMapper mapper = new ObjectMapper();
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/UserServiceTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/UserControllerTest.java
similarity index 98%
rename from full/src/test/java/de/ids_mannheim/korap/web/service/full/UserServiceTest.java
rename to full/src/test/java/de/ids_mannheim/korap/web/controller/UserControllerTest.java
index 9fbf0be..3cb66f2 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/UserServiceTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/UserControllerTest.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.web.service.full;
+package de.ids_mannheim.korap.web.controller;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
@@ -34,7 +34,7 @@
import de.ids_mannheim.korap.exceptions.StatusCodes;
import de.ids_mannheim.korap.utils.JsonUtils;
import de.ids_mannheim.korap.utils.TimeUtils;
-import de.ids_mannheim.korap.web.service.FastJerseyTest;
+import de.ids_mannheim.korap.web.FastJerseyTest;
/** EM: To do: not implemented in the new DB yet
* @author hanl
@@ -44,7 +44,7 @@
// todo: do benchmarks for simple request to check access_token check and user
// retrieval!
@Ignore
-public class UserServiceTest extends FastJerseyTest {
+public class UserControllerTest extends FastJerseyTest {
@Autowired
HttpAuthorizationHandler handler;
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/UserGroupServiceTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/UserGroupControllerTest.java
similarity index 98%
rename from full/src/test/java/de/ids_mannheim/korap/web/service/full/UserGroupServiceTest.java
rename to full/src/test/java/de/ids_mannheim/korap/web/controller/UserGroupControllerTest.java
index 5a975a6..e59e6b5 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/UserGroupServiceTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/UserGroupControllerTest.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.web.service.full;
+package de.ids_mannheim.korap.web.controller;
import static org.junit.Assert.assertEquals;
@@ -21,7 +21,7 @@
import de.ids_mannheim.korap.exceptions.StatusCodes;
import de.ids_mannheim.korap.utils.JsonUtils;
-public class UserGroupServiceTest extends SpringJerseyTest {
+public class UserGroupControllerTest extends SpringJerseyTest {
@Autowired
private HttpAuthorizationHandler handler;
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/VirtualCorpusServiceTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/VirtualCorpusControllerTest.java
similarity index 85%
rename from full/src/test/java/de/ids_mannheim/korap/web/service/full/VirtualCorpusServiceTest.java
rename to full/src/test/java/de/ids_mannheim/korap/web/controller/VirtualCorpusControllerTest.java
index 0e02f2b..32fa94a 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/VirtualCorpusServiceTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/VirtualCorpusControllerTest.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.web.service.full;
+package de.ids_mannheim.korap.web.controller;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -27,13 +27,11 @@
import de.ids_mannheim.korap.config.Attributes;
import de.ids_mannheim.korap.config.AuthenticationScheme;
import de.ids_mannheim.korap.config.SpringJerseyTest;
-import de.ids_mannheim.korap.dao.VirtualCorpusDao;
-import de.ids_mannheim.korap.entity.VirtualCorpus;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.exceptions.StatusCodes;
import de.ids_mannheim.korap.utils.JsonUtils;
-public class VirtualCorpusServiceTest extends SpringJerseyTest {
+public class VirtualCorpusControllerTest extends SpringJerseyTest {
@Autowired
private HttpAuthorizationHandler handler;
@@ -94,10 +92,53 @@
}
@Test
+ public void testCreatePublishVC () throws KustvaktException {
+ String json =
+ "{\"name\": \"new published vc\",\"type\": \"PUBLISHED\",\"createdBy\": "
+ + "\"test class\",\"corpusQuery\": \"corpusSigle=GOE\"}";
+ ClientResponse response = resource().path("vc").path("create")
+ .header(Attributes.AUTHORIZATION,
+ handler.createBasicAuthorizationHeaderValue(
+ "test class", "pass"))
+ .header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32")
+ .header(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON)
+ .post(ClientResponse.class, json);
+
+ assertEquals(Status.OK.getStatusCode(), response.getStatus());
+
+ // test list owner vc
+ response = resource().path("vc").path("list").path("user")
+ .header(Attributes.AUTHORIZATION,
+ handler.createBasicAuthorizationHeaderValue(
+ "test class", "pass"))
+ .header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32")
+
+ .get(ClientResponse.class);
+
+ String entity = response.getEntity(String.class);
+ System.out.println(entity);
+ JsonNode node = JsonUtils.readTree(entity);
+ assertEquals(1, node.size());
+ assertEquals("new published vc", node.get(0).get("name").asText());
+ // cannot explicitly checked hidden groups here
+
+ String vcId = node.get(0).get("id").asText();
+
+ // delete vc
+ resource().path("vc").path("delete").queryParam("vcId", vcId)
+ .header(Attributes.AUTHORIZATION,
+ handler.createBasicAuthorizationHeaderValue(
+ "test class", "pass"))
+ .header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32")
+
+ .delete(ClientResponse.class);
+ }
+
+ @Test
public void testCreateDeleteVC () throws KustvaktException {
String json =
"{\"name\": \"new vc\",\"type\": \"PRIVATE\",\"createdBy\": "
- + "\"test class\",\"collectionQuery\": \"corpusSigle=GOE\"}";
+ + "\"test class\",\"corpusQuery\": \"corpusSigle=GOE\"}";
ClientResponse response = resource().path("vc").path("create")
.header(Attributes.AUTHORIZATION,
@@ -158,7 +199,7 @@
throws IOException, KustvaktException {
String json =
"{\"name\": \"new vc\",\"type\": \"PRIVATE\",\"createdBy\": "
- + "\"test class\",\"collectionQuery\": \"corpusSigle=GOE\"}";
+ + "\"test class\",\"corpusQuery\": \"corpusSigle=GOE\"}";
InputStream is = getClass().getClassLoader()
.getResourceAsStream("test-user.token");
@@ -189,7 +230,7 @@
public void testCreateVCUnauthorized () throws KustvaktException {
String json =
"{\"name\": \"new vc\",\"type\": \"PRIVATE\",\"createdBy\": "
- + "\"test class\",\"collectionQuery\": \"creationDate since 1820\"}";
+ + "\"test class\",\"corpusQuery\": \"creationDate since 1820\"}";
ClientResponse response = resource().path("vc").path("create")
.header(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON)
@@ -208,7 +249,7 @@
}
@Test
- public void testCreateVCWithoutCollectionQuery () throws KustvaktException {
+ public void testCreateVCWithoutcorpusQuery () throws KustvaktException {
String json =
"{\"name\": \"new vc\",\"type\": \"PRIVATE\",\"createdBy\": "
+ "\"test class\"}";
@@ -226,14 +267,14 @@
JsonNode node = JsonUtils.readTree(entity);
assertEquals(StatusCodes.INVALID_ARGUMENT,
node.at("/errors/0/0").asInt());
- assertEquals("collectionQuery", node.at("/errors/0/1").asText());
+ assertEquals("corpusQuery", node.at("/errors/0/1").asText());
assertEquals("null", node.at("/errors/0/2").asText());
}
@Test
public void testCreateVCWithoutType () throws KustvaktException {
String json = "{\"name\": \"new vc\",\"createdBy\": "
- + "\"test class\",\"collectionQuery\": \"creationDate since 1820\"}";
+ + "\"test class\",\"corpusQuery\": \"creationDate since 1820\"}";
ClientResponse response = resource().path("vc").path("create")
.header(Attributes.AUTHORIZATION,
@@ -256,7 +297,7 @@
public void testCreateVCWithWrongType () throws KustvaktException {
String json =
"{\"name\": \"new vc\",\"type\": \"PRIVAT\",\"createdBy\": "
- + "\"test class\",\"collectionQuery\": \"creationDate since 1820\"}";
+ + "\"test class\",\"corpusQuery\": \"creationDate since 1820\"}";
ClientResponse response = resource().path("vc").path("create")
.header(Attributes.AUTHORIZATION,
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/service/full/KustvaktServerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/service/full/KustvaktServerTest.java
deleted file mode 100644
index 1466056..0000000
--- a/full/src/test/java/de/ids_mannheim/korap/web/service/full/KustvaktServerTest.java
+++ /dev/null
@@ -1,371 +0,0 @@
-package de.ids_mannheim.korap.web.service.full;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.UUID;
-
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.utils.URIBuilder;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.HttpClients;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.core.util.MultivaluedMapImpl;
-
-import de.ids_mannheim.korap.authentication.http.HttpAuthorizationHandler;
-import de.ids_mannheim.korap.config.Attributes;
-import de.ids_mannheim.korap.config.BeanConfigTest;
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.handlers.ResourceDao;
-import de.ids_mannheim.korap.resources.KustvaktResource;
-import de.ids_mannheim.korap.resources.Permissions.Permission;
-import de.ids_mannheim.korap.user.User;
-import de.ids_mannheim.korap.utils.JsonUtils;
-
-/**
- * This class tests services of a running Kustvakt server with a MySQL
- * database.
- * Please check the database configuration in
- * src/main/resources/jdbc.properties
- * and run the server before running the tests.
- *
- * See {@link ResourceServiceTest} for tests using an in-memory
- * database.
- *
- * @author margaretha
- *
- */
-@Ignore
-@Deprecated
-public class KustvaktServerTest extends BeanConfigTest {
- private static ObjectMapper mapper = new ObjectMapper();
- @Autowired
- private HttpAuthorizationHandler handler;
-
-
- @Test
- public void testRegisterBadPassword ()
- throws URISyntaxException, ClientProtocolException, IOException, KustvaktException {
- HttpClient httpClient = HttpClients.createDefault();
-
- MultivaluedMap<String, String> map = new MultivaluedMapImpl();
- map.putSingle("username", "kusvakt");
- map.putSingle("email", "kustvakt@ids-mannheim.de");
- map.putSingle("password", "password");
- map.putSingle("firstName", "kustvakt");
- map.putSingle("lastName", "user");
- map.putSingle("address", "Mannheim");
-
- URIBuilder builder = new URIBuilder();
- builder.setScheme("http").setHost("localhost").setPort(8089)
- .setPath("/api/v0.1/user/register");
- URI uri = builder.build();
- HttpPost httppost = new HttpPost(uri);
- StringEntity entity = new StringEntity(JsonUtils.toJSON(map));
- httppost.setEntity(entity);
- httppost.addHeader(HttpHeaders.CONTENT_TYPE,
- MediaType.APPLICATION_JSON);
- httppost.addHeader(HttpHeaders.USER_AGENT, "Apache HTTP Client");
- httppost.addHeader(HttpHeaders.HOST, "localhost");
-
- HttpResponse response = httpClient.execute(httppost);
- assertEquals(ClientResponse.Status.NOT_ACCEPTABLE.getStatusCode(),
- response.getStatusLine().getStatusCode());
-
- HttpEntity responseEntity = response.getEntity();
- JsonNode errorNode = mapper.readTree(responseEntity.getContent());
- assertEquals(
- "[The value for the parameter password is not valid or acceptable.]",
- errorNode.get("errors").get(0).get(2).asText());
-
- }
-
-
- @Test
- public void testRegisterExistingUsername ()
- throws URISyntaxException, ClientProtocolException, IOException, KustvaktException {
- HttpClient httpClient = HttpClients.createDefault();
-
- MultivaluedMap<String, String> map = new MultivaluedMapImpl();
- map.putSingle("username", "kustvakt");
- map.putSingle("email", "kustvakt@ids-mannheim.de");
- map.putSingle("password", "password1234");
- map.putSingle("firstName", "kustvakt");
- map.putSingle("lastName", "user");
- map.putSingle("address", "Mannheim");
-
- URIBuilder builder = new URIBuilder();
- builder.setScheme("http").setHost("localhost").setPort(8089)
- .setPath("/api/v0.1/user/register");
- URI uri = builder.build();
- HttpPost httppost = new HttpPost(uri);
- StringEntity entity = new StringEntity(JsonUtils.toJSON(map));
- httppost.setEntity(entity);
- httppost.addHeader(HttpHeaders.CONTENT_TYPE,
- MediaType.APPLICATION_JSON);
- httppost.addHeader(HttpHeaders.USER_AGENT, "Apache HTTP Client");
- httppost.addHeader(HttpHeaders.HOST, "localhost");
-
- HttpResponse response = httpClient.execute(httppost);
- assertEquals(ClientResponse.Status.BAD_REQUEST.getStatusCode(),
- response.getStatusLine().getStatusCode());
-
- HttpEntity responseEntity = response.getEntity();
- JsonNode errorNode = mapper.readTree(responseEntity.getContent());
- assertEquals(
- "[The value for the parameter password is not valid or acceptable.]",
- errorNode.get("errors").asText());
- }
-
-
- @Test
- public void testRegisterUser ()
- throws URISyntaxException, ClientProtocolException, IOException, KustvaktException {
- HttpClient httpClient = HttpClients.createDefault();
-
- MultivaluedMap<String, String> map = new MultivaluedMapImpl();
- map.putSingle("username", "testUser");
- map.putSingle("email", "testUser@ids-mannheim.de");
- map.putSingle("password", "testPassword1234");
- map.putSingle("firstName", "test");
- map.putSingle("lastName", "user");
- map.putSingle("address", "Mannheim");
-
- URIBuilder builder = new URIBuilder();
- builder.setScheme("http").setHost("localhost").setPort(8089)
- .setPath("/api/v0.1/user/register");
- URI uri = builder.build();
- HttpPost httppost = new HttpPost(uri);
- StringEntity entity = new StringEntity(JsonUtils.toJSON(map));
- httppost.setEntity(entity);
- httppost.addHeader(HttpHeaders.CONTENT_TYPE,
- MediaType.APPLICATION_JSON);
- httppost.addHeader(HttpHeaders.USER_AGENT, "Apache HTTP Client");
- httppost.addHeader(HttpHeaders.HOST, "localhost");
-
- HttpResponse response = httpClient.execute(httppost);
- assertEquals(ClientResponse.Status.OK.getStatusCode(),
- response.getStatusLine().getStatusCode());
-
- }
-
-
- @Test
- public void testCreatePolicy () throws IOException, URISyntaxException, KustvaktException {
-
- HttpClient httpClient = HttpClients.createDefault();
-
- String id = UUID.randomUUID().toString();
- URIBuilder builder = new URIBuilder();
- builder.setScheme("http").setHost("localhost").setPort(8089)
- .setPath("/api/v0.1/admin/createPolicies/" + id)
- .setParameter("type", "virtualcollection")
- .setParameter("name", "Goethe VC")
- .setParameter("description", "Goethe corpus")
- .setParameter("group", "public")
- .setParameter("perm", Permission.READ.name())
- .setParameter("loc", "").setParameter("expire", "");
-
- URI uri = builder.build();
- HttpPost httppost = new HttpPost(uri);
-
- httppost.addHeader(Attributes.AUTHORIZATION,
- handler.createBasicAuthorizationHeaderValue("kustvakt", "kustvakt2015"));
- HttpResponse response = httpClient.execute(httppost);
- assertEquals(ClientResponse.Status.OK.getStatusCode(),
- response.getStatusLine().getStatusCode());
-
- }
-
-
- @Test
- public void testCreatePolicyForFoundry ()
- throws IOException, URISyntaxException, KustvaktException {
-
- HttpClient httpClient = HttpClients.createDefault();
-
- String id = UUID.randomUUID().toString();
- URIBuilder builder = new URIBuilder();
- builder.setScheme("http").setHost("localhost").setPort(8089)
- .setPath("/api/v0.1/admin/createPolicies/" + id)
- .setParameter("type", "foundry")
- .setParameter("name", "stanford")
- .setParameter("description", "stanford parser")
- .setParameter("group", "public")
- .setParameter("perm", Permission.READ.name())
- .setParameter("loc", "255.255.255.0")
- .setParameter("expire", "30D");
-
- URI uri = builder.build();
- HttpPost httppost = new HttpPost(uri);
-
- httppost.addHeader(Attributes.AUTHORIZATION,
- handler.createBasicAuthorizationHeaderValue("kustvakt", "kustvakt2015"));
- HttpResponse response = httpClient.execute(httppost);
- assertEquals(ClientResponse.Status.OK.getStatusCode(),
- response.getStatusLine().getStatusCode());
-
- }
-
-
- @Test
- public void testCreatePolicyWithMultiplePermissions ()
- throws IOException, URISyntaxException, KustvaktException {
-
- HttpClient httpClient = HttpClients.createDefault();
-
- String id = UUID.randomUUID().toString();
- URIBuilder builder = new URIBuilder();
- builder.setScheme("http").setHost("localhost").setPort(8089)
- .setPath("/api/v0.1/admin/createPolicies/" + id)
- .setParameter("type", "corpus").setParameter("name", "Brown")
- .setParameter("description", "Brown corpus")
- .setParameter("group", "public")
- .setParameter("perm", Permission.READ.name())
- .setParameter("perm", Permission.WRITE.name())
- .setParameter("perm", Permission.DELETE.name())
- .setParameter("loc", "255.255.255.0")
- .setParameter("expire", "30D");
-
- URI uri = builder.build();
- HttpPost httppost = new HttpPost(uri);
-
- httppost.addHeader(Attributes.AUTHORIZATION,
- handler.createBasicAuthorizationHeaderValue("kustvakt", "kustvakt2015"));
- HttpResponse response = httpClient.execute(httppost);
- assertEquals(ClientResponse.Status.OK.getStatusCode(),
- response.getStatusLine().getStatusCode());
-
- }
-
-
- @Test
- public void testWrongAuthorization ()
- throws IOException, URISyntaxException, KustvaktException {
- HttpResponse response = testResourceStore("wezrowerowj");
- assertEquals(ClientResponse.Status.UNAUTHORIZED.getStatusCode(),
- response.getStatusLine().getStatusCode());
- }
-
-
- @Test
- public void testCorrectAuthorization ()
- throws IOException, URISyntaxException, KustvaktException {
-
- HttpResponse response = testResourceStore("kustvakt2015");
- HttpEntity entity = response.getEntity();
- String content = null;
-
- if (entity != null) {
- InputStream is = entity.getContent();
- try {
- content = IOUtils.toString(is, "UTF-8");
- }
- finally {
- is.close();
- }
- }
-
- assertEquals(ClientResponse.Status.OK.getStatusCode(),
- response.getStatusLine().getStatusCode());
-
- JsonNode node = JsonUtils.readTree(content);
- assertNotNull(node);
- assertTrue(node.isObject());
- assertEquals("Goethe", node.path("name").asText());
- assertEquals("Goethe corpus", node.path("description").asText());
- }
-
-
- public HttpResponse testResourceStore (String password)
- throws IOException, URISyntaxException, KustvaktException {
-
- HttpClient httpclient = HttpClients.createDefault();
- URIBuilder builder = new URIBuilder();
- builder.setScheme("http").setHost("localhost").setPort(8089)
- .setPath("/api/v0.1/virtualcollection")
- .setParameter("filter", "httpclient")
- .setParameter("name", "Goethe")
- .setParameter("description", "Goethe corpus");
- URI uri = builder.build();
- HttpPost httppost = new HttpPost(uri);
- httppost.addHeader(Attributes.AUTHORIZATION,
- handler.createBasicAuthorizationHeaderValue("kustvakt", password));
- return httpclient.execute(httppost);
-
- }
-
- @Test
- public void testResourceUpdate ()
- throws IOException, URISyntaxException, KustvaktException {
-
- HttpClient httpclient = HttpClients.createDefault();
- URIBuilder builder = new URIBuilder();
- builder.setScheme("http").setHost("localhost").setPort(8089)
- //.setPath("/api/v0.1/virtualcollection/00df953b-2227-4c23-84c1-5532c07bf8ce")
- .setPath("/api/v0.1/virtualcollection/GOE-VC")
- .setParameter("name", "Goethe collection")
- .setParameter("description", "Goethe collection");
- URI uri = builder.build();
- HttpPost httppost = new HttpPost(uri);
- httppost.addHeader(Attributes.AUTHORIZATION,
- handler.createBasicAuthorizationHeaderValue("kustvakt", "kustvakt2015"));
- HttpResponse response = httpclient.execute(httppost);
-
- assertEquals(ClientResponse.Status.OK.getStatusCode(),
- response.getStatusLine().getStatusCode());
-
-// assertEquals(ClientResponse.Status.BAD_REQUEST.getStatusCode(),
-// response.getStatusLine().getStatusCode());
-
-// JsonNode errorNode = mapper.readTree(response.getEntity().getContent());
-// assertEquals(
-// "Resource not found!",
-// errorNode.get("errors").get(0).get(1).asText());
-
- }
-
-
- private void checkResourceInDB (String id) throws KustvaktException {
-
- ResourceDao<?> dao = new ResourceDao<>(
- helper().getContext().getPersistenceClient());
- assertEquals("sqlite",
- helper().getContext().getPersistenceClient().getDatabase());
-
- assertNotEquals(0, dao.size());
- KustvaktResource res = dao.findbyId(id, User.UserFactory.getDemoUser());
- assertNotNull(res);
- Assert.assertEquals(true,
- res.getField("testVar").toString().startsWith("testVal_"));
- }
-
-
- @Override
- public void initMethod () throws KustvaktException {
- // TODO Auto-generated method stub
-
- }
-}