[ARVADOS] updated: c4fcddbe2a01ebbc3a4898dfa8744eb6fc45227e

git at public.curoverse.com git at public.curoverse.com
Tue Apr 29 09:15:19 EDT 2014


Summary of changes:
 sdk/java/pom.xml                                   |    5 +
 .../java/org/arvados/sdk/java/ArvadosTest.java     |   88 ++++++++++++-------
 2 files changed, 60 insertions(+), 33 deletions(-)

       via  c4fcddbe2a01ebbc3a4898dfa8744eb6fc45227e (commit)
      from  84c471b1cfb20116b2d7d26215c2517cb57ba53f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit c4fcddbe2a01ebbc3a4898dfa8744eb6fc45227e
Author: radhika <radhika at radhika>
Date:   Tue Apr 29 09:14:18 2014 -0400

    2525: Add pipeline template create testing. Use maven resources for input files.

diff --git a/sdk/java/pom.xml b/sdk/java/pom.xml
index dfd12f7..a8df534 100644
--- a/sdk/java/pom.xml
+++ b/sdk/java/pom.xml
@@ -87,5 +87,10 @@
           </executions>
         </plugin>
       </plugins>
+      <resources>
+    	<resource>
+          <directory>src/test/resources</directory>      
+        </resource>
+      </resources>
     </build>
 </project>
diff --git a/sdk/java/src/test/java/org/arvados/sdk/java/ArvadosTest.java b/sdk/java/src/test/java/org/arvados/sdk/java/ArvadosTest.java
index b42fbeb..e2dbc19 100644
--- a/sdk/java/src/test/java/org/arvados/sdk/java/ArvadosTest.java
+++ b/sdk/java/src/test/java/org/arvados/sdk/java/ArvadosTest.java
@@ -1,13 +1,12 @@
 package org.arvados.sdk.java;
 
-import java.io.BufferedWriter;
 import java.io.File;
-import java.io.FileWriter;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
 import org.junit.Test;
+
 import static org.junit.Assert.*;
 
 import com.google.api.services.discovery.model.RestDescription;
@@ -67,7 +66,6 @@ public class ArvadosTest {
     // The discover method returns the supported methods
     Map<String, RestResource> resources = restDescription.getResources();
     assertNotNull("Expected resources", resources);
-    //assertNotNull("Expected methods", restDescription.getMethods());
 
     Object users = resources.get("users");
     assertNotNull ("Expected users.list method", users);
@@ -91,12 +89,12 @@ public class ArvadosTest {
     params.add("v1");
     params.add("users.list");
 
-    String callResponse = arv.call(params);
-    assertTrue("Expected users.list in response", callResponse.contains("arvados#userList"));
-    assertTrue("Expected users.list in response", callResponse.contains("uuid"));
+    String response = arv.call(params);
+    assertTrue("Expected users.list in response", response.contains("arvados#userList"));
+    assertTrue("Expected users.list in response", response.contains("uuid"));
 
     JSONParser parser = new JSONParser();
-    Object obj = parser.parse(callResponse);
+    Object obj = parser.parse(response);
     JSONObject jsonObject = (JSONObject) obj;
 
     assertEquals("Expected kind to be users.list", "arvados#userList", jsonObject.get("kind"));
@@ -127,9 +125,9 @@ public class ArvadosTest {
     params.add("v1");
     params.add("users.list");
 
-    String callResponse = arv.call(params);
+    String response = arv.call(params);
     JSONParser parser = new JSONParser();
-    Object obj = parser.parse(callResponse);
+    Object obj = parser.parse(response);
     JSONObject jsonObject = (JSONObject) obj;
     assertNotNull("expected users list", jsonObject);
     List items = (List)jsonObject.get("items");
@@ -146,10 +144,10 @@ public class ArvadosTest {
     params.add("users.get");
     params.add(userUuid);
 
-    callResponse = arv.call(params);
+    response = arv.call(params);
 
     //JSONParser parser = new JSONParser();
-    jsonObject = (JSONObject) parser.parse(callResponse);;
+    jsonObject = (JSONObject) parser.parse(response);;
     assertNotNull("Expected uuid for first user", jsonObject.get("uuid"));
     assertEquals("Expected system user uuid", userUuid, jsonObject.get("uuid"));
   }
@@ -162,26 +160,21 @@ public class ArvadosTest {
   public void testCreateUser() throws Exception {
     Arvados arv = new Arvados("arvados");
 
-    // POST request needs an input file
-    File file = new File("/tmp/arvados_test.json");
-    BufferedWriter output = new BufferedWriter(new FileWriter(file));
-    output.write("{}");
-    output.close();
+    File file = new File(getClass().getResource( "/create_user.json" ).toURI());
+    String filePath = file.getPath();
 
     List<String> params = new ArrayList<String>();
     params.add("call");
     params.add("arvados");
     params.add("v1");
     params.add("users.create");
-    params.add("/tmp/arvados_test.json");
-    String callResponse = arv.call(params);
+    params.add(filePath);
+    String response = arv.call(params);
 
     JSONParser parser = new JSONParser();
-    JSONObject jsonObject = (JSONObject) parser.parse(callResponse);
+    JSONObject jsonObject = (JSONObject) parser.parse(response);
     assertEquals("Expected kind to be user", "arvados#user", jsonObject.get("kind"));
     assertNotNull("Expected uuid for first user", jsonObject.get("uuid"));
-    
-    file.delete();
   }
 
   /**
@@ -192,12 +185,6 @@ public class ArvadosTest {
   public void testUnsupportedApiName() throws Exception {
     Arvados arv = new Arvados("not_arvados");
 
-    // POST request needs an input file
-    File file = new File("/tmp/arvados_test.json");
-    BufferedWriter output = new BufferedWriter(new FileWriter(file));
-    output.write("{}");
-    output.close();
-
     List<String> params = new ArrayList<String>();
     params.add("call");
     params.add("not_arvados");
@@ -223,12 +210,6 @@ public class ArvadosTest {
   public void testUnsupportedVersion() throws Exception {
     Arvados arv = new Arvados("arvados");
 
-    // POST request needs an input file
-    File file = new File("/tmp/arvados_test.json");
-    BufferedWriter output = new BufferedWriter(new FileWriter(file));
-    output.write("{}");
-    output.close();
-
     List<String> params = new ArrayList<String>();
     params.add("call");
     params.add("arvados");
@@ -270,4 +251,45 @@ public class ArvadosTest {
     assertTrue ("Expected ERROR: missing method name", caught.getMessage().contains("ERROR: missing method name"));
   }
   
+  /**
+   * Test pipeline_tempates.create api
+   * @throws Exception
+   */
+  @Test
+  public void testCreateAndGetPipelineTemplate() throws Exception {
+    Arvados arv = new Arvados("arvados");
+
+    File file = new File(getClass().getResource( "/first_pipeline.json" ).toURI());
+    String filePath = file.getPath();
+
+    List<String> params = new ArrayList<String>();
+    params.add("call");
+    params.add("arvados");
+    params.add("v1");
+    params.add("pipeline_templates.create");
+    params.add(filePath);
+    String response = arv.call(params);
+
+    JSONParser parser = new JSONParser();
+    JSONObject jsonObject = (JSONObject) parser.parse(response);
+    assertEquals("Expected kind to be user", "arvados#pipelineTemplate", jsonObject.get("kind"));
+    String uuid = (String)jsonObject.get("uuid");
+    assertNotNull("Expected uuid for pipeline template", uuid);
+    
+    // get the pipeline
+    params = new ArrayList<String>();
+    params.add("call");
+    params.add("arvados");
+    params.add("v1");
+    params.add("pipeline_templates.get");
+    params.add(uuid);
+    response = arv.call(params);
+
+    parser = new JSONParser();
+    jsonObject = (JSONObject) parser.parse(response);
+    assertEquals("Expected kind to be user", "arvados#pipelineTemplate", jsonObject.get("kind"));
+    assertEquals("Expected uuid for pipeline template", uuid, jsonObject.get("uuid"));
+  }
+
+
 }
\ No newline at end of file

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list