airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ramin...@apache.org
Subject [1/3] git commit: Fixed experiment data model and helper classes for unit testing. AIRAVATA-1025
Date Thu, 20 Feb 2014 20:56:35 GMT
Repository: airavata
Updated Branches:
  refs/heads/master c28577ea9 -> 362812602


Fixed experiment data model and helper classes for unit testing. AIRAVATA-1025


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/ca3f8c4b
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/ca3f8c4b
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/ca3f8c4b

Branch: refs/heads/master
Commit: ca3f8c4b4485faa755aab8e95d5783734330bc33
Parents: ed47131
Author: raminder <raminder@apache.org>
Authored: Thu Feb 20 15:05:00 2014 -0500
Committer: raminder <raminder@apache.org>
Committed: Thu Feb 20 15:05:00 2014 -0500

----------------------------------------------------------------------
 .../jpa/resources/AbstractResource.java         | 24 ++++++-------
 .../registry/jpa/resources/Utils.java           |  2 +-
 .../registry/jpa/AbstractResourceTest.java      | 17 +++++++++
 .../registry/jpa/ExperimentResourceTest.java    | 36 ++++++++------------
 4 files changed, 45 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/ca3f8c4b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java
b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java
index f90a5b1..1e6adcb 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java
@@ -143,18 +143,18 @@ public abstract class AbstractResource implements Resource {
 
 	// Experiment table
 	public final class ExperimentConstants {
-		public static final String PROJECT_NAME = "project_name";
-		public static final String EXECUTION_USER = "execution_user";
-		public static final String GATEWAY_NAME = "gateway_name";
-		public static final String EXPERIMENT_ID = "experiment_id";
-		public static final String EXPERIMENT_NAME = "experiment_name";
-		public static final String DESCRIPTION = "experiment_description";
-		public static final String CREATION_TIME = "creation_time";
-		public static final String APPLICATION_ID = "application_id";
-		public static final String APPLICATION_VERSION = "application_version";
-		public static final String WORKFLOW_TEMPLATE_ID = "workflow_template_id";
-		public static final String WORKFLOW_TEMPLATE_VERSION = "workflow_template_version";
-		public static final String WORKFLOW_EXECUTION_ID = "workflow_execution_id";
+		public static final String PROJECT_NAME = "projectName";
+		public static final String EXECUTION_USER = "executionUser";
+		public static final String GATEWAY_NAME = "gatewayName";
+		public static final String EXPERIMENT_ID = "expId";
+		public static final String EXPERIMENT_NAME = "expName";
+		public static final String DESCRIPTION = "expDesc";
+		public static final String CREATION_TIME = "creationTime";
+		public static final String APPLICATION_ID = "applicationId";
+		public static final String APPLICATION_VERSION = "appVersion";
+		public static final String WORKFLOW_TEMPLATE_ID = "workflowTemplateId";
+		public static final String WORKFLOW_TEMPLATE_VERSION = "workflowTemplateVersion";
+		public static final String WORKFLOW_EXECUTION_ID = "workflowExecutionId";
 	}
 
     // Experiment Configuration Data table

http://git-wip-us.apache.org/repos/asf/airavata/blob/ca3f8c4b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java
b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java
index 5f3709d..e823ed9 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java
@@ -469,7 +469,7 @@ public class Utils {
     private static Resource createGatewayWorker(Gateway_Worker o) {
         GatewayResource gatewayResource = new GatewayResource(o.getGateway().getGateway_name());
         gatewayResource.setOwner(o.getGateway().getOwner());
-        WorkerResource workerResource = new WorkerResource(o.getUser().getUser_name(), gatewayResource);
+        WorkerResource workerResource = new WorkerResource(o.getUser_name(), gatewayResource);
         return workerResource;
     }
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/ca3f8c4b/modules/registry/airavata-jpa-registry/src/test/java/org/apache/airavata/persistance/registry/jpa/AbstractResourceTest.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/test/java/org/apache/airavata/persistance/registry/jpa/AbstractResourceTest.java
b/modules/registry/airavata-jpa-registry/src/test/java/org/apache/airavata/persistance/registry/jpa/AbstractResourceTest.java
index 40ad4e2..5d356e4 100644
--- a/modules/registry/airavata-jpa-registry/src/test/java/org/apache/airavata/persistance/registry/jpa/AbstractResourceTest.java
+++ b/modules/registry/airavata-jpa-registry/src/test/java/org/apache/airavata/persistance/registry/jpa/AbstractResourceTest.java
@@ -22,7 +22,9 @@
 package org.apache.airavata.persistance.registry.jpa;
 
 import junit.framework.TestCase;
+
 import org.apache.airavata.persistance.registry.jpa.resources.GatewayResource;
+import org.apache.airavata.persistance.registry.jpa.resources.ProjectResource;
 import org.apache.airavata.persistance.registry.jpa.resources.UserResource;
 import org.apache.airavata.persistance.registry.jpa.resources.WorkerResource;
 import org.apache.airavata.persistance.registry.jpa.util.Initialize;
@@ -35,6 +37,7 @@ public abstract class AbstractResourceTest extends TestCase {
     private GatewayResource gatewayResource;
     private WorkerResource workerResource;
     private UserResource userResource;
+    private ProjectResource projectResource;
 
     private Initialize initialize;
     @Override
@@ -43,9 +46,15 @@ public abstract class AbstractResourceTest extends TestCase {
         initialize.initializeDB();
         gatewayResource = (GatewayResource)ResourceUtils.getGateway("default");
         workerResource = (WorkerResource)ResourceUtils.getWorker(gatewayResource.getGatewayName(),
"admin");
+        projectResource = (ProjectResource)workerResource.create(ResourceType.PROJECT);
+        projectResource.setGateway(gatewayResource);
+        projectResource.setName("default");
+        projectResource.setWorker(workerResource);
+        projectResource.save();
         userResource = (UserResource)gatewayResource.create(ResourceType.USER);
         userResource.setUserName("admin");
         userResource.setPassword("admin");
+        userResource.save();
     }
 
     public Timestamp getCurrentTimestamp() {
@@ -71,5 +80,13 @@ public abstract class AbstractResourceTest extends TestCase {
         return userResource;
     }
 
+	public ProjectResource getProjectResource() {
+		return projectResource;
+	}
+
+	public void setProjectResource(ProjectResource projectResource) {
+		this.projectResource = projectResource;
+	}
+
 
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/ca3f8c4b/modules/registry/airavata-jpa-registry/src/test/java/org/apache/airavata/persistance/registry/jpa/ExperimentResourceTest.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/test/java/org/apache/airavata/persistance/registry/jpa/ExperimentResourceTest.java
b/modules/registry/airavata-jpa-registry/src/test/java/org/apache/airavata/persistance/registry/jpa/ExperimentResourceTest.java
index 63d88be..c8d1851 100644
--- a/modules/registry/airavata-jpa-registry/src/test/java/org/apache/airavata/persistance/registry/jpa/ExperimentResourceTest.java
+++ b/modules/registry/airavata-jpa-registry/src/test/java/org/apache/airavata/persistance/registry/jpa/ExperimentResourceTest.java
@@ -27,22 +27,16 @@ import java.sql.Timestamp;
 import java.util.Calendar;
 
 public class ExperimentResourceTest extends AbstractResourceTest {
-    private GatewayResource gatewayResource;
     private ExperimentResource experimentResource;
-    private WorkerResource workerResource;
+    private String experimentID = "testExpID";
  
     @Override
     public void setUp() throws Exception {
     	super.setUp();
-        gatewayResource = super.getGatewayResource();
-        workerResource = super.getWorkerResource();
-    }
-
-    public void testCreate() throws Exception {
-        experimentResource = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
-        experimentResource.setExpID("testExpID");
-        experimentResource.setWorker(workerResource);
-        experimentResource.setProject(new ProjectResource(workerResource, gatewayResource,
"testProject"));
+        experimentResource = (ExperimentResource) getGatewayResource().create(ResourceType.EXPERIMENT);
+        experimentResource.setExpID(experimentID);
+        experimentResource.setWorker(getWorkerResource());
+        experimentResource.setProject(getProjectResource());
         Calendar calender = Calendar.getInstance();
         java.util.Date d = calender.getTime();
         Timestamp currentDate = new Timestamp(d.getTime());
@@ -51,24 +45,24 @@ public class ExperimentResourceTest extends AbstractResourceTest {
         experimentResource.setApplicationVersion("1.0");
         experimentResource.setDescription("Test Application");
         experimentResource.setExpName("TestExperiment");
-        experimentResource.save();
-    	assertNotNull("experiment data resource has being created ", experimentResource);
+    	experimentResource.save();
     }
+    
 
-    public void testGet() throws Exception {
-      //  assertNotNull("experiment data retrieved successfully", experimentResource.get(ResourceType.EXPERIMENT_DATA,
"testExpID"));
+    public void testCreate() throws Exception {
+    	assertNotNull("experiment data resource has being created ", experimentResource);
     }
 
     public void testSave() throws Exception {
-      //  experimentResource.save();
-      //  assertTrue("experiment save successfully", gatewayResource.isExists(ResourceType.EXPERIMENT,
"testExpID"));
+        assertTrue("experiment save successfully", getGatewayResource().isExists(ResourceType.EXPERIMENT,
experimentID));
+    }
+    public void testGet() throws Exception {
+        assertNotNull("experiment data retrieved successfully", getGatewayResource().get(ResourceType.EXPERIMENT,
experimentID));
     }
 
     public void testRemove() throws Exception {
-//        if (!experimentDataResource.isWorkflowInstancePresent("testWFInstance")){
-//            experimentResource.remove(ResourceType.EXPERIMENT_DATA, "testExpID");
-//            assertTrue("experiment data removed successfully", !experimentResource.isExists(ResourceType.EXPERIMENT_DATA,
"testExpID"));
-//        }
+    	getGatewayResource().remove(ResourceType.EXPERIMENT, experimentID);
+      assertTrue("experiment data removed successfully", !getGatewayResource().isExists(ResourceType.EXPERIMENT,
experimentID));        
     }
 
     @Override


Mime
View raw message