Setup creating marlin-vc and published-vc in VirtualCorpusTestBase

instead of using SQL for testing

Change-Id: Ieb13db4518373234b989fa2c97b6d4cc24e1f24b
diff --git a/Changes b/Changes
index 36550ed..845b4ec 100644
--- a/Changes
+++ b/Changes
@@ -9,7 +9,8 @@
   for testing 
 - Setup creating group-vc in VirtualCorpusTestBase instead of using SQL 
   for testing 
-
+- Setup creating marlin-vc and published-vc in VirtualCorpusTestBase 
+  instead of using SQL for testing 
 
 # version 0.76
 
diff --git a/src/main/resources/db/test/V3.1__insert_virtual_corpus.sql b/src/main/resources/db/test/V3.1__insert_virtual_corpus.sql
index 3126057..f7be688 100644
--- a/src/main/resources/db/test/V3.1__insert_virtual_corpus.sql
+++ b/src/main/resources/db/test/V3.1__insert_virtual_corpus.sql
@@ -73,13 +73,13 @@
 --	VALUES ("system-vc", "SYSTEM", "VIRTUAL_CORPUS", "ALL", "system", "test vc", "experimental",
 --	'{"collection":{"@type":"koral:doc","value":"GOE","match":"match:eq","key":"corpusSigle"}}');
 
-INSERT INTO query(name, type, query_type, required_access, created_by, description, status, koral_query) 
-	VALUES ("published-vc", "PUBLISHED", "VIRTUAL_CORPUS", "ALL", "marlin", "test vc", "experimental",
-	'{"collection":{"@type":"koral:doc","value":"GOE","match":"match:eq","key":"corpusSigle"}}');
+--INSERT INTO query(name, type, query_type, required_access, created_by, description, status, koral_query) 
+--	VALUES ("published-vc", "PUBLISHED", "VIRTUAL_CORPUS", "ALL", "marlin", "test vc", "experimental",
+--	'{"collection":{"@type":"koral:doc","value":"GOE","match":"match:eq","key":"corpusSigle"}}');
 
-INSERT INTO query(name, type, query_type, required_access, created_by, description, status, koral_query) 
-	VALUES ("marlin-vc", "PRIVATE", "VIRTUAL_CORPUS", "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 query(name, type, query_type, required_access, created_by, description, status, koral_query) 
+--	VALUES ("marlin-vc", "PRIVATE", "VIRTUAL_CORPUS", "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 query(name, type, query_type, required_access, created_by, description, status, koral_query) 
 --	VALUES ("nemo-vc", "PRIVATE", "VIRTUAL_CORPUS", "ALL", "nemo", "nemo test vc", "experimental",
diff --git a/src/test/java/de/ids_mannheim/korap/dao/VirtualCorpusDaoTest.java b/src/test/java/de/ids_mannheim/korap/dao/VirtualCorpusDaoTest.java
index f3015e8..f816da7 100644
--- a/src/test/java/de/ids_mannheim/korap/dao/VirtualCorpusDaoTest.java
+++ b/src/test/java/de/ids_mannheim/korap/dao/VirtualCorpusDaoTest.java
@@ -26,16 +26,17 @@
     @Test
     public void testListVCByType () throws KustvaktException {
     	createDoryVC();
+    	createMarlinPublishedVC();
     	
         List<QueryDO> vcList = dao.retrieveQueryByType(ResourceType.PUBLISHED,
                 null, QueryType.VIRTUAL_CORPUS);
         assertEquals(1, vcList.size());
         QueryDO vc = vcList.get(0);
-        assertEquals(1, vc.getId());
         assertEquals("published-vc", vc.getName());
         assertEquals("marlin", vc.getCreatedBy());
         
         deleteVC("dory-vc", "dory", "dory");
+        deleteVC("published-vc", "marlin", "marlin");
     }
 
     @Test
@@ -134,13 +135,19 @@
      */
     @Test
     public void retrieveVCByUserMarlin () throws KustvaktException {
+    	createMarlinVC();
+    	createMarlinPublishedVC();
+    	
         List<QueryDO> virtualCorpora = dao.retrieveQueryByUser("marlin",
                 QueryType.VIRTUAL_CORPUS);
         assertEquals(3, virtualCorpora.size());
         Iterator<QueryDO> i = virtualCorpora.iterator();
-        assertEquals("published-vc",i.next().getName());
-        assertEquals("marlin-vc",i.next().getName());
         assertEquals("system-vc",i.next().getName());
+        assertEquals("marlin-vc",i.next().getName());
+        assertEquals("published-vc",i.next().getName());
+        
+        deleteVC("marlin-vc", "marlin", "marlin");
+        deleteVC("published-vc", "marlin", "marlin");
     }
 
     /**
diff --git a/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusControllerAdminTest.java b/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusControllerAdminTest.java
index 6678ca1..4c82125 100644
--- a/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusControllerAdminTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusControllerAdminTest.java
@@ -166,6 +166,7 @@
     @Test
     public void testShareVC () throws ProcessingException, KustvaktException {
         createMarlinGroup();
+        createMarlinVC();
         
         String vcCreator = "marlin";
         String vcName = "marlin-vc";
@@ -197,5 +198,6 @@
         assertEquals(0, node2.size());
         
         deleteGroupByName(marlinGroupName, "marlin");
+        deleteVC("marlin-vc", "marlin", "marlin");
     }
 }
diff --git a/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusListTest.java b/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusListTest.java
index fea59c7..254bf8e 100644
--- a/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusListTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusListTest.java
@@ -51,10 +51,16 @@
     @Test
     public void testListVCMarlin ()
             throws ProcessingException, KustvaktException {
+    	createMarlinVC();
+    	createMarlinPublishedVC();
+    	
         JsonNode node = testListOwnerVC("marlin");
         assertEquals(2, node.size());
         node = listVC("marlin");
         assertEquals(3, node.size());
+        
+        deleteVC("marlin-vc", "marlin", "marlin");
+        deleteVC("published-vc", "marlin", "marlin");
     }
 
     
diff --git a/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusPublishedTest.java b/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusPublishedTest.java
index a0d9918..1078c39 100644
--- a/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusPublishedTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusPublishedTest.java
@@ -96,6 +96,8 @@
     public void testMarlinPublishedVC () throws KustvaktException {
         createDoryVC();
     	createDoryGroupVC();
+    	createMarlinVC();
+    	createMarlinPublishedVC();
         
         JsonNode node = testListOwnerVC("marlin");
         assertEquals(2, node.size());
@@ -126,6 +128,8 @@
         deleteGroupByName(marlinGroupName, "marlin");
         deleteVC("dory-vc", "dory", "dory");
         deleteVC("group-vc", "dory", "dory");
+        deleteVC("marlin-vc", "marlin", "marlin");
+        deleteVC("published-vc", "marlin", "marlin");
     }
     
     private String testSharePublishedVC (String vcName) throws KustvaktException {
diff --git a/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusReferenceTest.java b/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusReferenceTest.java
index 4dc67e7..21833c6 100644
--- a/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusReferenceTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusReferenceTest.java
@@ -175,6 +175,7 @@
 
     @Test
     public void testSearchWithRefPublishedVcGuest () throws KustvaktException {
+    	createMarlinPublishedVC();
         Response response = target().path(API_VERSION).path("search")
                 .queryParam("q", "[orth=der]").queryParam("ql", "poliqarp")
                 .queryParam("cq", "referTo \"marlin/published-vc\"").request()
@@ -197,6 +198,7 @@
                 node.at("/rewrites/0/original/@type").asText());
         assertEquals("marlin/published-vc",
                 node.at("/rewrites/0/original/ref").asText());
+        deleteVC("published-vc", "marlin", "marlin");
     }
 
     @Test
diff --git a/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusSharingTest.java b/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusSharingTest.java
index 96cfab2..cb24364 100644
--- a/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusSharingTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusSharingTest.java
@@ -45,6 +45,7 @@
 
     @Test
     public void testShareVC_Unauthorized () throws KustvaktException {
+    	createMarlinVC();
         Response response = target().path(API_VERSION).path("vc")
                 .path("~marlin").path("marlin-vc").path("share")
                 .path("@marlin group").request()
@@ -52,6 +53,7 @@
                         .createBasicAuthorizationHeaderValue("dory", "pass"))
                 .post(Entity.form(new Form()));
         testResponseUnauthorized(response, "dory");
+        deleteVC("marlin-vc", "marlin", "marlin");
     }
 
     @Test
diff --git a/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusTestBase.java b/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusTestBase.java
index 3645df3..8843e51 100644
--- a/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusTestBase.java
+++ b/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusTestBase.java
@@ -78,6 +78,15 @@
 				+ "1810\"}";
 		createVC(authHeader, "dory", "group-vc", vcJson);
 	}
+	
+	protected void createMarlinVC() throws KustvaktException {
+    	createVC("marlin", "marlin-vc", ResourceType.PRIVATE);
+    };
+    
+    protected void createMarlinPublishedVC() throws KustvaktException {
+    	createVC("marlin", "published-vc", ResourceType.PUBLISHED);
+    };
+    
     
     protected void createVC (String authHeader, String username, String vcName,
             String vcJson) throws KustvaktException {