Updated VC name pattern and tests.
Change-Id: I96fff8ff831a310b3406d8f68f00f45c4074b5c3
diff --git a/full/Changes b/full/Changes
index c4998cc..36a4c52 100644
--- a/full/Changes
+++ b/full/Changes
@@ -16,6 +16,8 @@
- Changed the response media-type of authentication controllers (margaretha)
- Fixed bugs: allow guest to retrieve system VC,
remove VC from cache when it is deleted (margaretha)
+04/07/2019
+ - Updated VC name pattern and tests (margaretha)
# version 0.61.6
04/02/2019
diff --git a/full/src/main/java/de/ids_mannheim/korap/service/VirtualCorpusService.java b/full/src/main/java/de/ids_mannheim/korap/service/VirtualCorpusService.java
index 6b530bc..e18d258 100644
--- a/full/src/main/java/de/ids_mannheim/korap/service/VirtualCorpusService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/service/VirtualCorpusService.java
@@ -59,7 +59,7 @@
public static boolean DEBUG = false;
- public static Pattern wordPattern = Pattern.compile("[-\\w. ]+");
+ public static Pattern vcNamePattern = Pattern.compile("[-\\w.]+");
@Autowired
private VirtualCorpusDao vcDao;
@@ -323,7 +323,7 @@
ParameterChecker.checkStringValue(name, "name");
ParameterChecker.checkObjectValue(type, "type");
- if (!wordPattern.matcher(name).matches()) {
+ if (!vcNamePattern.matcher(name).matches()) {
throw new KustvaktException(StatusCodes.INVALID_ARGUMENT,
"Virtual corpus name must only contains letters, numbers, "
+ "underscores, hypens and spaces",
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/controller/VirtualCorpusController.java b/full/src/main/java/de/ids_mannheim/korap/web/controller/VirtualCorpusController.java
index 87a98c8..6c979ff 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/controller/VirtualCorpusController.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/controller/VirtualCorpusController.java
@@ -40,6 +40,8 @@
/**
* VirtualCorpusController defines web APIs related to virtual corpus
* (VC) such as creating, deleting and listing user virtual corpora.
+ * All the APIs in this class are available to logged-in users, except
+ * retrieving info of system VC.
*
* This class also includes APIs related to virtual corpus access
* (VCA) such as sharing and publishing VC. When a VC is published,
@@ -47,7 +49,8 @@
* VC. It is listed for a user, once when he/she have searched for the
* VC. A VC can be published by creating or editing the VC.
*
- * All the APIs in this class are available to logged-in users.
+ * VC name must follow the following regex [a-zA-Z_0-9-.], other
+ * characters are not allowed.
*
* @author margaretha
*
diff --git a/full/src/main/resources/db/test/V3.1__insert_virtual_corpus.sql b/full/src/main/resources/db/test/V3.1__insert_virtual_corpus.sql
index 7d11ce6..3a0a054 100644
--- a/full/src/main/resources/db/test/V3.1__insert_virtual_corpus.sql
+++ b/full/src/main/resources/db/test/V3.1__insert_virtual_corpus.sql
@@ -62,57 +62,57 @@
-- virtual corpora
INSERT INTO virtual_corpus(name, type, required_access, created_by, description, status, corpus_query)
- VALUES ("dory VC", "PRIVATE", "FREE", "dory", "test vc", "experimental",
+ VALUES ("dory-vc", "PRIVATE", "FREE", "dory", "test vc", "experimental",
'{"collection": { "@type": "koral:docGroup", "operands": [ { "@type": "koral:doc", "key": "corpusSigle", "match": "match:eq", "value": "GOE" }, { "@type": "koral:doc", "key": "creationDate", "match": "match:geq", "type": "type:date", "value": "1820" } ], "operation": "operation:and" }}');
INSERT INTO virtual_corpus(name, type, required_access, created_by, description, status, corpus_query)
- VALUES ("group VC", "PROJECT", "PUB", "dory", "test vc", "experimental",
+ VALUES ("group-vc", "PROJECT", "PUB", "dory", "test vc", "experimental",
'{"collection": { "@type": "koral:docGroup", "operands": [ { "@type": "koral:doc", "key": "corpusSigle", "match": "match:eq", "value": "GOE" }, { "@type": "koral:doc", "key": "creationDate", "match": "match:leq", "type": "type:date", "value": "1810" } ], "operation": "operation:and" }}');
INSERT INTO virtual_corpus(name, type, required_access, created_by, description, status, corpus_query)
- VALUES ("system VC", "SYSTEM", "ALL", "system", "test vc", "experimental",
+ VALUES ("system-vc", "SYSTEM", "ALL", "system", "test vc", "experimental",
'{"collection":{"@type":"koral:doc","value":"GOE","match":"match:eq","key":"corpusSigle"}}');
INSERT INTO virtual_corpus(name, type, required_access, created_by, description, status, corpus_query)
- VALUES ("published VC", "PUBLISHED", "ALL", "marlin", "test vc", "experimental",
+ VALUES ("published-vc", "PUBLISHED", "ALL", "marlin", "test vc", "experimental",
'{"collection":{"@type":"koral:doc","value":"GOE","match":"match:eq","key":"corpusSigle"}}');
INSERT INTO virtual_corpus(name, type, required_access, created_by, description, status, corpus_query)
- VALUES ("marlin VC", "PRIVATE", "FREE", "marlin", "marlin test share vc", "experimental",
+ VALUES ("marlin-vc", "PRIVATE", "FREE", "marlin", "marlin test share vc", "experimental",
'{"collection": { "@type": "koral:docGroup", "operands": [ { "@type": "koral:doc", "key": "corpusSigle", "match": "match:eq", "value": "GOE" }, { "@type": "koral:doc", "key": "creationDate", "match": "match:geq", "type": "type:date", "value": "1820" } ], "operation": "operation:and" }}');
INSERT INTO virtual_corpus(name, type, required_access, created_by, description, status, corpus_query)
- VALUES ("nemo VC", "PRIVATE", "ALL", "nemo", "nemo test vc", "experimental",
+ VALUES ("nemo-vc", "PRIVATE", "ALL", "nemo", "nemo test vc", "experimental",
'{"collection":{"@type":"koral:doc","value":"GOE","match":"match:eq","key":"corpusSigle"}}');
-- virtual corpus access
INSERT INTO virtual_corpus_access(virtual_corpus_id, user_group_id, status, created_by)
SELECT
- (SELECT id from virtual_corpus where name = "group VC"),
+ (SELECT id from virtual_corpus where name = "group-vc"),
(SELECT id from user_group where name = "dory group"),
"ACTIVE", "dory";
--INSERT INTO virtual_corpus_access(virtual_corpus_id, user_group_id, status, created_by)
-- SELECT
--- (SELECT id from virtual_corpus where name = "system VC"),
+-- (SELECT id from virtual_corpus where name = "system-vc"),
-- (SELECT id from user_group where name = "all users"),
-- "ACTIVE", "system";
INSERT INTO virtual_corpus_access(virtual_corpus_id, user_group_id, status, created_by)
SELECT
- (SELECT id from virtual_corpus where name = "published VC"),
+ (SELECT id from virtual_corpus where name = "published-vc"),
(SELECT id from user_group where name = "marlin group"),
"ACTIVE", "marlin";
INSERT INTO virtual_corpus_access(virtual_corpus_id, user_group_id, status, created_by)
SELECT
- (SELECT id from virtual_corpus where name = "published VC"),
+ (SELECT id from virtual_corpus where name = "published-vc"),
(SELECT id from user_group where name = "auto group"),
"HIDDEN", "system";
-- Summary user VC Lists
--- dory: dory VC, group VC, system VC
--- nemo: group VC, system VC
--- marlin: published VC, system VC
--- pearl: system VC, published VC
+-- dory: dory-vc, group-vc, system-vc
+-- nemo: group-vc, system-vc
+-- marlin: published-vc, system-vc
+-- pearl: system-vc, published-vc
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 98bd936..525f64a 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,14 +34,14 @@
VirtualCorpus vc = vcList.get(0);
assertEquals(4, vc.getId());
- assertEquals("published VC", vc.getName());
+ assertEquals("published-vc", vc.getName());
assertEquals("marlin", vc.getCreatedBy());
}
@Test
public void testSystemVC () throws KustvaktException {
// insert vc
- int id = dao.createVirtualCorpus("system VC", VirtualCorpusType.SYSTEM,
+ int id = dao.createVirtualCorpus("system-vc", VirtualCorpusType.SYSTEM,
User.CorpusAccess.FREE, "corpusSigle=GOE", "definition",
"description", "experimental", false, "test class");
@@ -64,7 +64,7 @@
thrown.expect(PersistenceException.class);
thrown.expectMessage("could not execute statement");
- dao.createVirtualCorpus("system VC", VirtualCorpusType.SYSTEM,
+ dao.createVirtualCorpus("system-vc", VirtualCorpusType.SYSTEM,
User.CorpusAccess.FREE, "corpusSigle=GOE", "definition",
"description", "experimental", false, "system");
}
@@ -88,10 +88,10 @@
assertEquals(4, virtualCorpora.size());
// ordered by id
Iterator<VirtualCorpus> i = virtualCorpora.iterator();
- assertEquals("dory VC", i.next().getName());
- assertEquals("group VC", i.next().getName());
- assertEquals("system VC", i.next().getName());
- assertEquals("published VC", i.next().getName());
+ assertEquals("dory-vc", i.next().getName());
+ assertEquals("group-vc", i.next().getName());
+ assertEquals("system-vc", i.next().getName());
+ assertEquals("published-vc", i.next().getName());
}
/**
@@ -105,9 +105,9 @@
List<VirtualCorpus> virtualCorpora = dao.retrieveVCByUser("nemo");
assertEquals(3, virtualCorpora.size());
Iterator<VirtualCorpus> i = virtualCorpora.iterator();
- assertEquals("group VC", i.next().getName());
- assertEquals("system VC", i.next().getName());
- assertEquals("nemo VC", i.next().getName());
+ assertEquals("group-vc", i.next().getName());
+ assertEquals("system-vc", i.next().getName());
+ assertEquals("nemo-vc", i.next().getName());
}
/**
@@ -121,9 +121,9 @@
List<VirtualCorpus> virtualCorpora = dao.retrieveVCByUser("marlin");
assertEquals(3, virtualCorpora.size());
Iterator<VirtualCorpus> i = virtualCorpora.iterator();
- assertEquals("system VC", i.next().getName());
- assertEquals("published VC", i.next().getName());
- assertEquals("marlin VC", i.next().getName());
+ assertEquals("system-vc", i.next().getName());
+ assertEquals("published-vc", i.next().getName());
+ assertEquals("marlin-vc", i.next().getName());
}
/**
@@ -137,8 +137,8 @@
List<VirtualCorpus> virtualCorpora = dao.retrieveVCByUser("pearl");
assertEquals(2, virtualCorpora.size());
Iterator<VirtualCorpus> i = virtualCorpora.iterator();
- assertEquals("system VC", i.next().getName());
- assertEquals("published VC", i.next().getName());
+ assertEquals("system-vc", i.next().getName());
+ assertEquals("published-vc", i.next().getName());
}
}
diff --git a/full/src/test/java/de/ids_mannheim/korap/rewrite/VirtualCorpusRewriteTest.java b/full/src/test/java/de/ids_mannheim/korap/rewrite/VirtualCorpusRewriteTest.java
index 6922522..b911877 100644
--- a/full/src/test/java/de/ids_mannheim/korap/rewrite/VirtualCorpusRewriteTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/rewrite/VirtualCorpusRewriteTest.java
@@ -85,7 +85,7 @@
throws KustvaktException, Exception {
ClientResponse response = resource().path(API_VERSION).path("search")
.queryParam("q", "[orth=der]").queryParam("ql", "poliqarp")
- .queryParam("cq", "referTo \"system VC\"")
+ .queryParam("cq", "referTo \"system-vc\"")
.get(ClientResponse.class);
String ent = response.getEntity(String.class);
@@ -110,7 +110,7 @@
public void testRewritePubAndSystemVCRef () throws KustvaktException {
ClientResponse response = resource().path(API_VERSION).path("search")
.queryParam("q", "[orth=der]").queryParam("ql", "poliqarp")
- .queryParam("cq", "referTo \"system/system VC\"")
+ .queryParam("cq", "referTo \"system/system-vc\"")
.header(Attributes.AUTHORIZATION, HttpAuthorizationHandler
.createBasicAuthorizationHeaderValue("user", "pass"))
.header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32")
@@ -135,7 +135,7 @@
ClientResponse response = resource().path(API_VERSION).path("search")
.queryParam("q", "Fisch").queryParam("ql", "poliqarp")
- .queryParam("cq", "referTo \"dory/dory VC\"")
+ .queryParam("cq", "referTo \"dory/dory-vc\"")
.header(Attributes.AUTHORIZATION, HttpAuthorizationHandler
.createBasicAuthorizationHeaderValue("dory", "pass"))
.get(ClientResponse.class);
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
index 89483d6..fbd95aa 100644
--- a/full/src/test/java/de/ids_mannheim/korap/service/VirtualCorpusServiceTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/service/VirtualCorpusServiceTest.java
@@ -46,12 +46,12 @@
VirtualCorpusJson vc = new VirtualCorpusJson();
vc.setCorpusQuery("corpusSigle=GOE");
vc.setType(VirtualCorpusType.PRIVATE);
- vcService.storeVC(vc, "dory VC", "dory");
+ vcService.storeVC(vc, "dory-vc", "dory");
}
@Test
public void createDeletePublishVC () throws KustvaktException {
- String vcName = "new published vc";
+ String vcName = "new-published-vc";
VirtualCorpusJson vc = new VirtualCorpusJson();
vc.setCorpusQuery("corpusSigle=GOE");
@@ -91,7 +91,7 @@
String username = "dory";
int vcId = 2;
- String vcName = "group VC";
+ String vcName = "group-vc";
VirtualCorpus existingVC =
vcService.searchVCByName(username, vcName, username);
VirtualCorpusJson vcJson = new VirtualCorpusJson();
@@ -128,7 +128,7 @@
// check VC
vcDto = vcService.searchVCById("dory", vcId);
- assertEquals("group VC", vcDto.getName());
+ assertEquals("group-vc", vcDto.getName());
assertEquals(VirtualCorpusType.PROJECT.displayName(), vcDto.getType());
// check access
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/VCReferenceTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/VCReferenceTest.java
index fc58ff8..31c34b6 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/VCReferenceTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/VCReferenceTest.java
@@ -129,7 +129,7 @@
public void testRefNotAuthorized() throws KustvaktException {
ClientResponse response = resource().path(API_VERSION).path("search")
.queryParam("q", "[orth=der]").queryParam("ql", "poliqarp")
- .queryParam("cq", "referTo \"dory/dory VC\"")
+ .queryParam("cq", "referTo \"dory/dory-vc\"")
.get(ClientResponse.class);
String ent = response.getEntity(String.class);
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/VirtualCorpusControllerAdminTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/VirtualCorpusControllerAdminTest.java
index 90ab155..33d2c26 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/VirtualCorpusControllerAdminTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/VirtualCorpusControllerAdminTest.java
@@ -33,7 +33,7 @@
public void testSearchPrivateVC () throws UniformInterfaceException,
ClientHandlerException, KustvaktException {
ClientResponse response = resource().path(API_VERSION).path("vc")
- .path("dory").path("dory VC")
+ .path("dory").path("dory-vc")
.header(Attributes.AUTHORIZATION, HttpAuthorizationHandler
.createBasicAuthorizationHeaderValue(admin, "pass"))
.header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32")
@@ -45,7 +45,7 @@
JsonNode node = JsonUtils.readTree(entity);
assertEquals(1, node.at("/id").asInt());
- assertEquals("dory VC", node.at("/name").asText());
+ assertEquals("dory-vc", node.at("/name").asText());
}
@Test
@@ -53,7 +53,7 @@
ClientHandlerException, KustvaktException {
ClientResponse response = resource().path(API_VERSION).path("vc")
- .path("dory").path("group VC")
+ .path("dory").path("group-vc")
.header(Attributes.AUTHORIZATION, HttpAuthorizationHandler
.createBasicAuthorizationHeaderValue(admin, "pass"))
.header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32")
@@ -63,7 +63,7 @@
assertEquals(Status.OK.getStatusCode(), response.getStatus());
JsonNode node = JsonUtils.readTree(entity);
- assertEquals("group VC", node.at("/name").asText());
+ assertEquals("group-vc", node.at("/name").asText());
assertEquals(VirtualCorpusType.PROJECT.displayName(),
node.at("/type").asText());
}
@@ -107,7 +107,7 @@
+ "\"corpusQuery\": \"creationDate since 1820\"}";
ClientResponse response = resource().path(API_VERSION).path("vc")
- .path(admin).path("new system vc")
+ .path(admin).path("new-system-vc")
.header(Attributes.AUTHORIZATION, HttpAuthorizationHandler
.createBasicAuthorizationHeaderValue(admin, "pass"))
.header(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON)
@@ -118,7 +118,7 @@
JsonNode node = testListSystemVC();
assertEquals(1, node.size());
- testDeleteSystemVC(admin, "new system vc");
+ testDeleteSystemVC(admin, "new-system-vc");
}
private void testDeleteSystemVC (String vcCreator, String vcName)
@@ -143,7 +143,7 @@
String json = "{\"type\": \"PRIVATE\","
+ "\"corpusQuery\": \"corpusSigle=GOE\"}";
- String vcName = "new vc";
+ String vcName = "new-vc";
ClientResponse response = resource().path(API_VERSION).path("vc")
.path(username).path(vcName)
.header(Attributes.AUTHORIZATION, HttpAuthorizationHandler
@@ -231,7 +231,7 @@
//
// assertEquals(admin, node.at("/createdBy").asText());
// assertEquals(5, node.at("/vcId").asInt());
-// assertEquals("marlin VC", node.at("/vcName").asText());
+// assertEquals("marlin-vc", node.at("/vcName").asText());
// assertEquals(1, node.at("/userGroupId").asInt());
// assertEquals("marlin group", node.at("/userGroupName").asText());
//
@@ -257,7 +257,7 @@
public void testVCSharing () throws UniformInterfaceException,
ClientHandlerException, KustvaktException {
String vcCreator = "marlin";
- String vcName = "marlin VC";
+ String vcName = "marlin-vc";
String groupName = "marlin group";
testCreateVCAccess(vcCreator, vcName, groupName);
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/VirtualCorpusControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/VirtualCorpusControllerTest.java
index 814799a..98a1328 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/VirtualCorpusControllerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/VirtualCorpusControllerTest.java
@@ -85,7 +85,6 @@
assertEquals(Status.OK.getStatusCode(), response.getStatus());
String entity = response.getEntity(String.class);
- // System.out.println(entity);
return JsonUtils.readTree(entity);
}
@@ -110,7 +109,6 @@
.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);
return node;
}
@@ -120,8 +118,8 @@
ClientHandlerException, KustvaktException {
JsonNode node = testSearchVC("VirtualCorpusControllerTest", "system",
- "system VC");
- assertEquals("system VC", node.at("/name").asText());
+ "system-vc");
+ assertEquals("system-vc", node.at("/name").asText());
assertEquals(VirtualCorpusType.SYSTEM.displayName(),
node.at("/type").asText());
}
@@ -131,9 +129,9 @@
ClientHandlerException, KustvaktException {
ClientResponse response = resource().path(API_VERSION).path("vc")
- .path("system").path("system VC").get(ClientResponse.class);
+ .path("system").path("system-vc").get(ClientResponse.class);
JsonNode node = JsonUtils.readTree(response.getEntity(String.class));
- assertEquals("system VC", node.at("/name").asText());
+ assertEquals("system-vc", node.at("/name").asText());
assertEquals(VirtualCorpusType.SYSTEM.displayName(),
node.at("/type").asText());
}
@@ -143,8 +141,8 @@
throws UniformInterfaceException, ClientHandlerException,
KustvaktException {
- JsonNode node = testSearchVC("dory", "dory", "dory VC");
- assertEquals("dory VC", node.at("/name").asText());
+ JsonNode node = testSearchVC("dory", "dory", "dory-vc");
+ assertEquals("dory-vc", node.at("/name").asText());
assertEquals(VirtualCorpusType.PRIVATE.displayName(),
node.at("/type").asText());
}
@@ -154,7 +152,7 @@
throws UniformInterfaceException, ClientHandlerException,
KustvaktException {
ClientResponse response = resource().path(API_VERSION).path("vc")
- .path("dory").path("dory VC")
+ .path("dory").path("dory-vc")
.header(Attributes.AUTHORIZATION,
HttpAuthorizationHandler
.createBasicAuthorizationHeaderValue(
@@ -177,8 +175,8 @@
public void testRetrieveProjectVCInfo () throws UniformInterfaceException,
ClientHandlerException, KustvaktException {
- JsonNode node = testSearchVC("nemo", "dory", "group VC");
- assertEquals("group VC", node.at("/name").asText());
+ JsonNode node = testSearchVC("nemo", "dory", "group-vc");
+ assertEquals("group-vc", node.at("/name").asText());
assertEquals(VirtualCorpusType.PROJECT.displayName(),
node.at("/type").asText());
}
@@ -189,7 +187,7 @@
KustvaktException {
ClientResponse response = resource().path(API_VERSION).path("vc")
- .path("dory").path("group VC")
+ .path("dory").path("group-vc")
.header(Attributes.AUTHORIZATION, HttpAuthorizationHandler
.createBasicAuthorizationHeaderValue("marlin", "pass"))
.header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32")
@@ -209,8 +207,8 @@
public void testRetrievePublishedVCInfo () throws UniformInterfaceException,
ClientHandlerException, KustvaktException {
- JsonNode node = testSearchVC("gill", "marlin", "published VC");
- assertEquals("published VC", node.at("/name").asText());
+ JsonNode node = testSearchVC("gill", "marlin", "published-vc");
+ assertEquals("published-vc", node.at("/name").asText());
assertEquals(VirtualCorpusType.PUBLISHED.displayName(),
node.at("/type").asText());
@@ -298,7 +296,7 @@
+ "\"corpusQuery\": \"corpusSigle=GOE\"}";
ClientResponse response = resource().path(API_VERSION).path("vc")
- .path("VirtualCorpusControllerTest").path("new vc")
+ .path("VirtualCorpusControllerTest").path("new_vc")
.header(Attributes.AUTHORIZATION,
HttpAuthorizationHandler
.createBasicAuthorizationHeaderValue(
@@ -312,10 +310,10 @@
// list user VC
JsonNode node = testListVC("VirtualCorpusControllerTest");
assertEquals(2, node.size());
- assertEquals("new vc", node.get(1).get("name").asText());
+ assertEquals("new_vc", node.get(1).get("name").asText());
// delete new VC
- testDeleteVC("new vc", "VirtualCorpusControllerTest");
+ testDeleteVC("new_vc", "VirtualCorpusControllerTest");
// list VC
node = testListVC("VirtualCorpusControllerTest");
@@ -327,7 +325,7 @@
String json = "{\"type\": \"PUBLISHED\""
+ ",\"corpusQuery\": \"corpusSigle=GOE\"}";
- String vcName = "new published vc";
+ String vcName = "new-published-vc";
ClientResponse response = resource().path(API_VERSION).path("vc")
.path("VirtualCorpusControllerTest").path(vcName)
@@ -352,7 +350,7 @@
assertEquals("system", node.at("/createdBy").asText());
assertEquals(vcName, node.at("/vcName").asText());
assertTrue(node.at("/userGroupName").asText().startsWith("auto"));
- assertEquals("new published vc", node.at("/vcName").asText());
+ assertEquals(vcName, node.at("/vcName").asText());
String groupId = node.at("/userGroupId").asText();
@@ -401,7 +399,7 @@
}
ClientResponse response = resource().path(API_VERSION).path("vc")
- .path("VirtualCorpusControllerTest").path("new vc")
+ .path("VirtualCorpusControllerTest").path("new_vc")
.header(Attributes.AUTHORIZATION,
AuthenticationScheme.API.displayName() + " "
+ authToken)
@@ -433,7 +431,7 @@
+ "CuYAfytr_LWqY8woJs";
ClientResponse response = resource().path(API_VERSION).path("vc")
- .path("VirtualCorpusControllerTest").path("new vc")
+ .path("VirtualCorpusControllerTest").path("new_vc")
.header(Attributes.AUTHORIZATION,
AuthenticationScheme.API.displayName() + " "
+ authToken)
@@ -458,7 +456,7 @@
+ "\"corpusQuery\": \"creationDate since 1820\"}";
ClientResponse response = resource().path(API_VERSION).path("vc")
- .path("VirtualCorpusControllerTest").path("new vc")
+ .path("VirtualCorpusControllerTest").path("new_vc")
.header(Attributes.AUTHORIZATION,
HttpAuthorizationHandler
.createBasicAuthorizationHeaderValue(
@@ -506,7 +504,7 @@
+ "\"corpusQuery\": \"creationDate since 1820\"}";
ClientResponse response = resource().path(API_VERSION).path("vc")
- .path("VirtualCorpusControllerTest").path("new vc")
+ .path("VirtualCorpusControllerTest").path("new_vc")
.header(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON)
.entity(json).put(ClientResponse.class);
@@ -527,7 +525,7 @@
String json = "{\"type\": \"PRIVATE\"}";
ClientResponse response = resource().path(API_VERSION).path("vc")
- .path("VirtualCorpusControllerTest").path("new vc")
+ .path("VirtualCorpusControllerTest").path("new_vc")
.header(Attributes.AUTHORIZATION,
HttpAuthorizationHandler
.createBasicAuthorizationHeaderValue(
@@ -548,7 +546,7 @@
@Test
public void testCreateVCWithoutEntity () throws KustvaktException {
ClientResponse response = resource().path(API_VERSION).path("vc")
- .path("VirtualCorpusControllerTest").path("new vc")
+ .path("VirtualCorpusControllerTest").path("new_vc")
.header(Attributes.AUTHORIZATION,
HttpAuthorizationHandler
.createBasicAuthorizationHeaderValue(
@@ -570,7 +568,7 @@
String json = "{\"corpusQuery\": " + "\"creationDate since 1820\"}";
ClientResponse response = resource().path(API_VERSION).path("vc")
- .path("VirtualCorpusControllerTest").path("new vc")
+ .path("VirtualCorpusControllerTest").path("new_vc")
.header(Attributes.AUTHORIZATION,
HttpAuthorizationHandler
.createBasicAuthorizationHeaderValue(
@@ -594,15 +592,15 @@
+ "\"corpusQuery\": \"creationDate since 1820\"}";
ClientResponse response = resource().path(API_VERSION).path("vc")
- .path("VirtualCorpusControllerTest").path("new vc")
+ .path("VirtualCorpusControllerTest").path("new_vc")
.header(Attributes.AUTHORIZATION,
HttpAuthorizationHandler
.createBasicAuthorizationHeaderValue(
"VirtualCorpusControllerTest", "pass"))
.header(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON)
.entity(json).put(ClientResponse.class);
+
String entity = response.getEntity(String.class);
- // System.out.println(entity);
assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
JsonNode node = JsonUtils.readTree(entity);
@@ -617,7 +615,7 @@
@Test
public void testDeleteVCUnauthorized () throws KustvaktException {
ClientResponse response = resource().path(API_VERSION).path("vc")
- .path("dory").path("dory VC")
+ .path("dory").path("dory-vc")
.header(Attributes.AUTHORIZATION,
HttpAuthorizationHandler
.createBasicAuthorizationHeaderValue(
@@ -646,7 +644,7 @@
String json = "{\"description\": \"edited vc\"}";
ClientResponse response = resource().path(API_VERSION).path("vc")
- .path("dory").path("dory VC")
+ .path("dory").path("dory-vc")
.header(Attributes.AUTHORIZATION, HttpAuthorizationHandler
.createBasicAuthorizationHeaderValue("dory", "pass"))
.header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32")
@@ -663,7 +661,7 @@
json = "{\"description\": \"test vc\"}";
response = resource().path(API_VERSION).path("vc").path("dory")
- .path("dory VC")
+ .path("dory-vc")
.header(Attributes.AUTHORIZATION, HttpAuthorizationHandler
.createBasicAuthorizationHeaderValue("dory", "pass"))
.header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32")
@@ -683,7 +681,7 @@
String json = "{\"corpusQuery\": \"corpusSigle=WPD17\"}";
ClientResponse response = resource().path(API_VERSION).path("vc")
- .path("dory").path("dory VC")
+ .path("dory").path("dory-vc")
.header(Attributes.AUTHORIZATION, HttpAuthorizationHandler
.createBasicAuthorizationHeaderValue("dory", "pass"))
.header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32")
@@ -705,7 +703,7 @@
String json = "{\"description\": \"edited vc\"}";
ClientResponse response = resource().path(API_VERSION).path("vc")
- .path("dory").path("dory VC")
+ .path("dory").path("dory-vc")
.header(Attributes.AUTHORIZATION,
HttpAuthorizationHandler
.createBasicAuthorizationHeaderValue(
@@ -729,7 +727,7 @@
@Test
public void testPublishProjectVC () throws KustvaktException {
- String vcName = "group VC";
+ String vcName = "group-vc";
// check the vc type
JsonNode node = testSearchVC("dory", "dory", vcName);
@@ -765,7 +763,7 @@
json = "{\"type\": \"PROJECT\"}";
response = resource().path(API_VERSION).path("vc").path("dory")
- .path("group VC")
+ .path("group-vc")
.header(Attributes.AUTHORIZATION, HttpAuthorizationHandler
.createBasicAuthorizationHeaderValue("dory", "pass"))
.header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32")
@@ -826,7 +824,7 @@
JsonNode node = JsonUtils.readTree(entity);
assertEquals(1, node.at("/0/accessId").asInt());
assertEquals(2, node.at("/0/vcId").asInt());
- assertEquals("group VC", node.at("/0/vcName").asText());
+ assertEquals("group-vc", node.at("/0/vcName").asText());
assertEquals(2, node.at("/0/userGroupId").asInt());
assertEquals("dory group", node.at("/0/userGroupName").asText());
@@ -836,7 +834,7 @@
public void testCreateDeleteAccess () throws UniformInterfaceException,
ClientHandlerException, KustvaktException {
- String vcName = "marlin VC";
+ String vcName = "marlin-vc";
String groupName = "marlin group";
// check the vc type
@@ -920,7 +918,7 @@
@Test
public void testShareUnknownGroup () throws UniformInterfaceException,
ClientHandlerException, KustvaktException {
- ClientResponse response = testShareVCByCreator("marlin", "marlin VC",
+ ClientResponse response = testShareVCByCreator("marlin", "marlin-vc",
"non-existing-group");
JsonNode node = JsonUtils.readTree(response.getEntity(String.class));
assertEquals(HttpStatus.SC_NOT_FOUND, response.getStatus());
@@ -934,7 +932,7 @@
// dory is VCA in marlin group
ClientResponse response = resource().path(API_VERSION).path("vc")
- .path("marlin").path("marlin VC").path("share")
+ .path("marlin").path("marlin-vc").path("share")
.path("marlin group")
.header(Attributes.AUTHORIZATION, HttpAuthorizationHandler
.createBasicAuthorizationHeaderValue("dory", "pass"))
@@ -956,7 +954,7 @@
// nemo is not VCA in marlin group
ClientResponse response = resource().path(API_VERSION).path("vc")
- .path("nemo").path("nemo VC").path("share").path("marlin group")
+ .path("nemo").path("nemo-vc").path("share").path("marlin group")
.header(Attributes.AUTHORIZATION, HttpAuthorizationHandler
.createBasicAuthorizationHeaderValue("nemo", "pass"))
.header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32")