airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [09/44] airavata git commit: Adding mongo-registry WIP
Date Sun, 07 Jun 2015 17:00:50 GMT
http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/test/java/org/apache/airavata/persistence/registry/mongo/ExperimentDaoTest.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-mongo-registry/src/test/java/org/apache/airavata/persistence/registry/mongo/ExperimentDaoTest.java
b/modules/registry/airavata-mongo-registry/src/test/java/org/apache/airavata/persistence/registry/mongo/ExperimentDaoTest.java
new file mode 100644
index 0000000..6b4d5cf
--- /dev/null
+++ b/modules/registry/airavata-mongo-registry/src/test/java/org/apache/airavata/persistence/registry/mongo/ExperimentDaoTest.java
@@ -0,0 +1,268 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.persistence.registry.mongo;
+
+import com.mongodb.MongoClient;
+import junit.framework.Assert;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType;
+import org.apache.airavata.model.workspace.experiment.*;
+import org.apache.airavata.persistance.registry.jpa.impl.RegistryFactory;
+import org.apache.airavata.persistance.registry.jpa.mongo.dao.ExperimentDao;
+import org.apache.airavata.persistance.registry.jpa.mongo.utils.MongoUtil;
+import org.apache.airavata.registry.cpi.Registry;
+import org.apache.airavata.registry.cpi.RegistryException;
+import org.apache.airavata.registry.cpi.RegistryModelType;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.List;
+import java.util.UUID;
+
+public class ExperimentDaoTest {
+    private final static Logger logger = LoggerFactory.getLogger(ExperimentDaoTest.class);
+
+    private static String gatewayId = "php_reference_gateway";
+
+    private static ExperimentDao experimentDao;
+    @BeforeClass
+    public static void setupBeforeClass() throws Exception{
+        experimentDao = new ExperimentDao();
+    }
+
+    @AfterClass
+    public static void tearDown(){
+        MongoClient mongoClient = MongoUtil.getMongoClient();
+        mongoClient.dropDatabase("airavata-data");
+    }
+
+    @Test
+    public void testExperimentDao() throws RegistryException {
+        String TAG = System.currentTimeMillis() + "";
+        //creating sample echo experiment
+        InputDataObjectType inputDataObjectType = new InputDataObjectType();
+        inputDataObjectType.setName("Input_to_Echo");
+        inputDataObjectType.setValue("Hello World");
+
+        ComputationalResourceScheduling scheduling = new ComputationalResourceScheduling();
+        scheduling.setResourceHostId(UUID.randomUUID().toString());
+        scheduling.setComputationalProjectAccount("TG-STA110014S");
+        scheduling.setTotalCpuCount(1);
+        scheduling.setNodeCount(1);
+        scheduling.setWallTimeLimit(15);
+        scheduling.setQueueName("normal");
+
+        UserConfigurationData userConfigurationData = new UserConfigurationData();
+        userConfigurationData.setAiravataAutoSchedule(false);
+        userConfigurationData.setOverrideManualScheduledParams(false);
+        userConfigurationData.setComputationalResourceScheduling(scheduling);
+
+        Experiment experiment = new Experiment();
+        experiment.setExperimentId("28395669237854235"+TAG);
+        experiment.setProjectId("2392519y92312341" + TAG);
+        experiment.setUserName("TestUser" + TAG);
+        experiment.setName("TestExperiment"+TAG);
+        experiment.setDescription("experiment");
+        experiment.setApplicationId("2358382458362846287"+TAG);
+        experiment.setUserConfigurationData(userConfigurationData);
+        experiment.addToExperimentInputs(inputDataObjectType);
+        experiment.setGatewayExecutionId("329619820461624214"+TAG);
+
+        experimentDao.createExperiment(experiment);
+        Experiment persistedExperiement = experimentDao.getExperiment(experiment.getExperimentId());
+        Assert.assertNotNull(persistedExperiement);
+        Assert.assertEquals(experiment, persistedExperiement);
+
+        experiment.setName("New Name"+TAG);
+        experimentDao.updateExperiment(experiment);
+        persistedExperiement = experimentDao.getExperiment(experiment.getExperimentId());
+        Assert.assertEquals(experiment, persistedExperiement);
+
+        List<Experiment> experimentList = experimentDao.getAllExperiments();
+        Assert.assertTrue(experimentList.size()==1);
+
+        experimentDao.deleteExperiment(experiment);
+        experimentList = experimentDao.getAllExperiments();
+        Assert.assertTrue(experimentList.size()==0);
+    }
+
+    @Test
+    public void test() throws RegistryException, IOException {
+        AiravataUtils.setExecutionAsServer();
+        Registry registry = RegistryFactory.getDefaultRegistry();
+        MongoUtil.dropAiravataRegistry();
+
+        ExperimentDao experimentDao = new ExperimentDao();
+        BufferedReader reader = new BufferedReader(new FileReader("/home/supun/Downloads/EXPERIMENT.csv"));
+        String temp = reader.readLine();
+        int i = 1;
+        long time1 = System.currentTimeMillis();
+        while(temp != null && !temp.isEmpty()){
+            try{
+                Experiment experiement = (Experiment) registry.get(RegistryModelType.EXPERIMENT,
temp.trim());
+                experimentDao.createExperiment(experiement);
+                Experiment persistedExperiment = experimentDao.getExperiment(temp.trim());
+//                List<Experiment> experimentList = experimentDao.getAllExperiments();
+                Assert.assertEquals(experiement, persistedExperiment);
+                System.out.println(i+" :"+experiement.getExperimentId());
+                i++;
+            }catch (Exception e){
+                System.out.println(temp);
+                e.printStackTrace();
+            }
+            temp = reader.readLine();
+        }
+        long time2  = System.currentTimeMillis();
+        System.out.println(time2-time1);
+    }
+
+    @Test
+    public void testGetExperimentOfWFNode() throws RegistryException, IOException {
+//        String nodeId = "IDontNeedaNode_48c545a1-bedd-46cf-90d4-e4390b129693";
+//        ExperimentDao experimentDao = new ExperimentDao();
+//        long time1 = System.currentTimeMillis();
+//        Experiment experiment = experimentDao.getExperimentOfWFNode(nodeId);
+//        long time2 = System.currentTimeMillis();
+//        System.out.println(time2-time1);
+//        Assert.assertNotNull(experiment);
+        AiravataUtils.setExecutionAsServer();
+
+        ExperimentDao experimentDao = new ExperimentDao();
+        BufferedReader reader = new BufferedReader(new FileReader("/home/supun/Downloads/WORKFLOW_NODE_DETAIL.csv"));
+        String temp = reader.readLine();
+        int i = 1;
+        int count  = 0;
+        long time1 = System.currentTimeMillis();
+        while(temp != null && !temp.isEmpty()){
+            try{
+                Experiment experiment = experimentDao.getExperimentOfWFNode(temp.trim());
+                if(experiment != null) {
+                    System.out.println(i + " :" + experiment.getExperimentId());
+                    count++;
+                }else{
+                    System.out.println("FAILED: " + temp);
+                }
+                i++;
+            }catch (Exception e){
+                System.out.println(temp);
+                e.printStackTrace();
+            }
+            temp = reader.readLine();
+        }
+        long time2  = System.currentTimeMillis();
+        System.out.println(count);
+        System.out.println(time2-time1);
+    }
+
+    @Test
+    public void testGetExperimentOfTask() throws RegistryException, IOException {
+//        String taskId = "tempNode_fceda7f7-267c-4197-bf20-a54f4fff395b";
+//        ExperimentDao experimentDao = new ExperimentDao();
+//        long time1 = System.currentTimeMillis();
+//        Experiment experiment = experimentDao.getExperimentOfTask(taskId);
+//        long time2 = System.currentTimeMillis();
+//        System.out.println(time2-time1);
+//        Assert.assertNotNull(experiment);
+//        AiravataUtils.setExecutionAsServer();
+//        Registry registry = RegistryFactory.getDefaultRegistry();
+//        MongoUtil.dropAiravataRegistry();
+        AiravataUtils.setExecutionAsServer();
+
+        ExperimentDao experimentDao = new ExperimentDao();
+        BufferedReader reader = new BufferedReader(new FileReader("/home/supun/Downloads/TASK_DETAIL.csv"));
+        String temp = reader.readLine();
+        int i = 1;
+        int count  = 0;
+        long time1 = System.currentTimeMillis();
+        while(temp != null && !temp.isEmpty()){
+            try{
+                Experiment experiment = experimentDao.getExperimentOfTask(temp.trim());
+                if(experiment != null) {
+                    //System.out.println(i + " :" + experiment.getExperimentId());
+                    count++;
+                }else{
+                    System.out.println("FAILED: " + temp);
+                }
+                i++;
+            }catch (Exception e){
+                System.out.println(temp);
+                e.printStackTrace();
+            }
+            temp = reader.readLine();
+        }
+        long time2  = System.currentTimeMillis();
+        System.out.println(count);
+        System.out.println(time2-time1);
+    }
+
+    @Test
+    public void testWorkFlow() throws RegistryException {
+        String nodeId = "tempNode_758b52ba-091b-43a5-a7b7-4c3a239c5d1e";
+        String newNodeId = "newNode_758b52ba-091b-43a5-a7b7-4c3a2325d1e";
+        String expId = "AlamoTest3_3965f4e2-0213-4434-9c3f-fe898b018666";
+        AiravataUtils.setExecutionAsServer();
+        ExperimentDao experimentDao = new ExperimentDao();
+        WorkflowNodeDetails wfNode = experimentDao.getWFNode("newNode_758b52ba-091b-43a5-a7b7-4c3a239c5d1e");
+        Assert.assertTrue(wfNode.getNodeInstanceId().equals("newNode_758b52ba-091b-43a5-a7b7-4c3a239c5d1e"));
+
+        wfNode.setNodeName("New2 Name"+System.currentTimeMillis());
+        experimentDao.updateWFNode(wfNode);
+        WorkflowNodeDetails updatedWfNode = experimentDao.getWFNode("newNode_758b52ba-091b-43a5-a7b7-4c3a239c5d1e");
+        Assert.assertTrue(updatedWfNode.getNodeName().equals(wfNode.getNodeName()));
+
+        WorkflowNodeDetails newWfNode = wfNode;
+        newWfNode.setTaskDetailsList(null);
+        newWfNode.setNodeInstanceId(newNodeId);
+        experimentDao.createWFNode(expId, newWfNode);
+
+        Experiment experiment = experimentDao.getExperiment(expId);
+
+        experimentDao.deleteWFNode(newWfNode);
+
+        experiment = experimentDao.getExperiment(expId);
+
+        System.out.println();
+    }
+
+    @Test
+    public void testTask() throws RegistryException {
+        String taskId = "tempNode_f43e1a37-5aec-4061-ae15-111a050b98e0";
+        AiravataUtils.setExecutionAsServer();
+        ExperimentDao experimentDao = new ExperimentDao();
+        TaskDetails taskDetails = experimentDao.getTaskDetail(taskId);
+        Assert.assertTrue(taskDetails.getTaskId().equals(taskId));
+
+        taskDetails.setTaskStatus(null);
+        experimentDao.updateTaskDetail(taskDetails);
+        taskDetails = experimentDao.getTaskDetail(taskId);
+        Assert.assertTrue(taskDetails.getTaskId().equals(taskId));
+
+        String expid = "AlamoTest1_6107d1f0-d64e-4690-8686-71ce87c4ad24";
+        Experiment experiment = experimentDao.getExperiment(expid);
+        System.out.println();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/test/java/org/apache/airavata/persistence/registry/mongo/org/apache/airavata/persistence/registry/RegistryUseCaseTest.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-mongo-registry/src/test/java/org/apache/airavata/persistence/registry/mongo/org/apache/airavata/persistence/registry/RegistryUseCaseTest.java
b/modules/registry/airavata-mongo-registry/src/test/java/org/apache/airavata/persistence/registry/mongo/org/apache/airavata/persistence/registry/RegistryUseCaseTest.java
new file mode 100644
index 0000000..0f0bd85
--- /dev/null
+++ b/modules/registry/airavata-mongo-registry/src/test/java/org/apache/airavata/persistence/registry/mongo/org/apache/airavata/persistence/registry/RegistryUseCaseTest.java
@@ -0,0 +1,291 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.persistence.registry.mongo.org.apache.airavata.persistence.registry;
+
+import junit.framework.Assert;
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.ServerSettings;
+import org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType;
+import org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType;
+import org.apache.airavata.model.workspace.Project;
+import org.apache.airavata.model.workspace.experiment.ComputationalResourceScheduling;
+import org.apache.airavata.model.workspace.experiment.Experiment;
+import org.apache.airavata.model.workspace.experiment.ExperimentSummary;
+import org.apache.airavata.model.workspace.experiment.UserConfigurationData;
+import org.apache.airavata.persistance.registry.jpa.impl.RegistryFactory;
+import org.apache.airavata.registry.cpi.*;
+import org.apache.airavata.registry.cpi.utils.Constants;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * This class contains test cases for the RegistryImpl class which is the default registry
+ * implementation. These test cases are written from the perspective of the Airavata API
+ * such as creating/updating/deleting/searching projects and experiments etc.
+ */
+public class RegistryUseCaseTest {
+
+    private static Registry registry;
+
+    @BeforeClass
+    public static void setupBeforeClass() throws RegistryException, SQLException {
+        registry = RegistryFactory.getDefaultRegistry();
+    }
+
+    @Test
+    public void testProject(){
+        try {
+            String TAG = System.currentTimeMillis() + "";
+
+            String gatewayId = ServerSettings.getDefaultUserGateway();
+
+            //testing the creation of a project
+            Project project = new Project();
+            project.setOwner("TestUser"+TAG);
+            project.setName("TestProject"+TAG);
+            project.setDescription("This is a test project"+TAG);
+            String projectId1 = (String)registry.add(ParentDataType.PROJECT, project, gatewayId);
+            Assert.assertNotNull(projectId1);
+
+            //testing the updateExperiment of a project
+            Project updatedProject = new Project();
+            updatedProject.setProjectId(projectId1);
+            updatedProject.setOwner("TestUser"+TAG);
+            updatedProject.setName("UpdatedTestProject"+TAG);
+            updatedProject.setDescription("This is an updated test project"+TAG);
+            registry.update(RegistryModelType.PROJECT, updatedProject, projectId1);
+
+            //testing project retrieval
+            Project retrievedProject = (Project)registry.get(RegistryModelType.PROJECT, projectId1);
+            Assert.assertEquals(updatedProject.getProjectId(), retrievedProject.getProjectId());
+            Assert.assertEquals(updatedProject.getOwner(), retrievedProject.getOwner());
+            Assert.assertEquals(updatedProject.getName(), retrievedProject.getName());
+            Assert.assertEquals(updatedProject.getDescription(), retrievedProject.getDescription());
+            Assert.assertNotNull(retrievedProject.getCreationTime());
+            //created user should be in the shared users list
+            Assert.assertTrue(retrievedProject.getSharedUsers().size()==1);
+
+            //creating more projects for the same user
+            project = new Project();
+            project.setOwner("TestUser"+TAG);
+            project.setName("Project Terrible"+TAG);
+            project.setDescription("This is a test project_2"+TAG);
+            String projectId2 = (String)registry.add(ParentDataType.PROJECT, project, gatewayId);
+            Assert.assertNotNull(projectId2);
+
+            project = new Project();
+            project.setOwner("TestUser"+TAG);
+            project.setName("Project Funny"+TAG);
+            project.setDescription("This is a test project_3"+TAG);
+            String projectId3 = (String)registry.add(ParentDataType.PROJECT, project, gatewayId);
+            Assert.assertNotNull(projectId3);
+
+            project = new Project();
+            project.setOwner("TestUser"+TAG);
+            project.setName("Project Stupid"+TAG);
+            project.setDescription("This is a test project_4"+TAG);
+            String projectId4 = (String)registry.add(ParentDataType.PROJECT, project, gatewayId);
+            Assert.assertNotNull(projectId4);
+
+            project = new Project();
+            project.setOwner("TestUser"+TAG);
+            project.setName("Project Boring"+TAG);
+            project.setDescription("This is a test project_5"+TAG);
+            String projectId5 = (String)registry.add(ParentDataType.PROJECT, project, gatewayId);
+            Assert.assertNotNull(projectId5);
+
+            //test getExperiment all projects created by the user
+            List<Object> list = registry.get(RegistryModelType.PROJECT,
+                    Constants.FieldConstants.ProjectConstants.OWNER, "TestUser"+TAG);
+            Assert.assertTrue(list.size()==5);
+
+            //search project by project name
+            Map<String, String> filters = new HashMap<String, String>();
+            filters.put(Constants.FieldConstants.ProjectConstants.OWNER, "TestUser"+TAG);
+            filters.put(Constants.FieldConstants.ProjectConstants.PROJECT_NAME, "Terrible"+TAG);
+            list = registry.search(RegistryModelType.PROJECT, filters);
+            Assert.assertTrue(list.size()==1);
+
+            //search project by project description
+            filters = new HashMap<String, String>();
+            filters.put(Constants.FieldConstants.ProjectConstants.OWNER, "TestUser"+TAG);
+            filters.put(Constants.FieldConstants.ProjectConstants.DESCRIPTION, "test project_2"+TAG);
+            list = registry.search(RegistryModelType.PROJECT, filters);
+            Assert.assertTrue(list.size()==1);
+
+            //search project with only ownername
+            filters = new HashMap<String, String>();
+            filters.put(Constants.FieldConstants.ProjectConstants.OWNER, "TestUser"+TAG);
+            list = registry.search(RegistryModelType.PROJECT, filters);
+            Assert.assertTrue(list.size()==5);
+
+            //search projects with pagination
+            filters = new HashMap<String, String>();
+            filters.put(Constants.FieldConstants.ProjectConstants.OWNER, "TestUser"+TAG);
+            list = registry.search(RegistryModelType.PROJECT, filters, 2, 2,
+                    Constants.FieldConstants.ProjectConstants.CREATION_TIME, ResultOrderType.DESC);
+            Assert.assertTrue(list.size()==2);
+            Project project1 = (Project)list.get(0);
+            Project project2 = (Project)list.get(1);
+            Assert.assertTrue(project1.getCreationTime()-project2.getCreationTime() >
0);
+        } catch (RegistryException e) {
+            e.printStackTrace();
+            Assert.fail();
+        } catch (ApplicationSettingsException e) {
+            e.printStackTrace();
+        }
+    }
+
+    @Test
+    public void testExperiment(){
+        try {
+            String TAG = System.currentTimeMillis() + "";
+
+            String gatewayId = ServerSettings.getDefaultUserGateway();
+
+            //creating project
+            Project project = new Project();
+            project.setOwner("TestUser"+TAG);
+            project.setName("TestProject"+TAG);
+            project.setDescription("This is a test project"+TAG);
+            String projectId1 = (String)registry.add(ParentDataType.PROJECT, project, gatewayId);
+            Assert.assertNotNull(projectId1);
+
+            //creating sample echo experiment. assumes echo application is already defined
+            InputDataObjectType inputDataObjectType = new InputDataObjectType();
+            inputDataObjectType.setName("Input_to_Echo");
+            inputDataObjectType.setValue("Hello World");
+
+            ComputationalResourceScheduling scheduling = new ComputationalResourceScheduling();
+            scheduling.setResourceHostId(UUID.randomUUID().toString());
+            scheduling.setComputationalProjectAccount("TG-STA110014S");
+            scheduling.setTotalCpuCount(1);
+            scheduling.setNodeCount(1);
+            scheduling.setWallTimeLimit(15);
+            scheduling.setQueueName("normal");
+
+            UserConfigurationData userConfigurationData = new UserConfigurationData();
+            userConfigurationData.setAiravataAutoSchedule(false);
+            userConfigurationData.setOverrideManualScheduledParams(false);
+            userConfigurationData.setComputationalResourceScheduling(scheduling);
+
+            Experiment experiment = new Experiment();
+            experiment.setProjectId(projectId1);
+            experiment.setUserName("TestUser" + TAG);
+            experiment.setName("TestExperiment"+TAG);
+            experiment.setDescription("Test 1 experiment");
+            experiment.setApplicationId(UUID.randomUUID().toString());
+            experiment.setUserConfigurationData(userConfigurationData);
+            experiment.addToExperimentInputs(inputDataObjectType);
+
+            String experimentId1 = (String)registry.add(ParentDataType.EXPERIMENT, experiment,
gatewayId);
+            Assert.assertNotNull(experimentId1);
+
+            //retrieving the stored experiment
+            Experiment retrievedExperiment = (Experiment)registry.get(RegistryModelType.EXPERIMENT,
+                    experimentId1);
+            Assert.assertNotNull(retrievedExperiment);
+            Assert.assertEquals(retrievedExperiment.getProjectId(), experiment.getProjectId());
+            Assert.assertEquals(retrievedExperiment.getDescription(), experiment.getDescription());
+            Assert.assertEquals(retrievedExperiment.getName(), experiment.getName());
+            Assert.assertEquals(retrievedExperiment.getApplicationId(), experiment.getApplicationId());
+            Assert.assertNotNull(retrievedExperiment.getUserConfigurationData());
+            Assert.assertNotNull(retrievedExperiment.getExperimentInputs());
+
+            //updating an existing experiment
+            experiment.setName("NewExperimentName"+TAG);
+            OutputDataObjectType outputDataObjectType = new OutputDataObjectType();
+            outputDataObjectType.setName("Output_to_Echo");
+            outputDataObjectType.setValue("Hello World");
+            experiment.addToExperimentOutputs(outputDataObjectType);
+            registry.update(RegistryModelType.EXPERIMENT, experiment, experimentId1);
+
+            //creating more experiments
+            experiment = new Experiment();
+            experiment.setProjectId(projectId1);
+            experiment.setUserName("TestUser" + TAG);
+            experiment.setName("TestExperiment2" + TAG);
+            experiment.setDescription("Test 2 experiment");
+            experiment.setApplicationId(UUID.randomUUID().toString());
+            experiment.setUserConfigurationData(userConfigurationData);
+            experiment.addToExperimentInputs(inputDataObjectType);
+
+            String experimentId2 = (String)registry.add(ParentDataType.EXPERIMENT, experiment,
gatewayId);
+            Assert.assertNotNull(experimentId2);
+
+            experiment = new Experiment();
+            experiment.setProjectId(projectId1);
+            experiment.setUserName("TestUser" + TAG);
+            experiment.setName("TestExperiment3"+TAG);
+            experiment.setDescription("Test 3 experiment");
+            experiment.setApplicationId(UUID.randomUUID().toString());
+            experiment.setUserConfigurationData(userConfigurationData);
+            experiment.addToExperimentInputs(inputDataObjectType);
+
+            String experimentId3 = (String)registry.add(ParentDataType.EXPERIMENT, experiment,
gatewayId);
+            Assert.assertNotNull(experimentId3);
+
+            //searching experiments by name
+            Map<String, String> filters = new HashMap<String, String>();
+            filters.put(Constants.FieldConstants.ExperimentConstants.USER_NAME, "TestUser"
+ TAG);
+            filters.put(Constants.FieldConstants.ExperimentConstants.GATEWAY, gatewayId);
+            filters.put(Constants.FieldConstants.ExperimentConstants.EXPERIMENT_NAME, "Experiment2");
+            List<Object> results = registry.search(RegistryModelType.EXPERIMENT, filters);
+            Assert.assertTrue(results.size()==1);
+
+            //retrieving all experiments in project
+            List<Object> list = registry.get(RegistryModelType.EXPERIMENT,
+                    Constants.FieldConstants.ExperimentConstants.PROJECT_ID, projectId1);
+            Assert.assertTrue(list.size()==3);
+
+            //searching all user experiments
+            filters = new HashMap<String, String>();
+            filters.put(Constants.FieldConstants.ExperimentConstants.USER_NAME, "TestUser"
+ TAG);
+            filters.put(Constants.FieldConstants.ExperimentConstants.GATEWAY, gatewayId);
+            list = registry.search(RegistryModelType.EXPERIMENT, filters);
+            Assert.assertTrue(list.size()==3);
+
+            //searching user experiemets with pagination
+            filters = new HashMap<String, String>();
+            filters.put(Constants.FieldConstants.ExperimentConstants.USER_NAME, "TestUser"
+ TAG);
+            filters.put(Constants.FieldConstants.ExperimentConstants.GATEWAY, gatewayId);
+            list = registry.search(RegistryModelType.EXPERIMENT, filters, 2, 1,
+                    Constants.FieldConstants.ExperimentConstants.CREATION_TIME, ResultOrderType.DESC);
+            Assert.assertTrue(list.size()==2);
+            ExperimentSummary exp1 = (ExperimentSummary)list.get(0);
+            ExperimentSummary exp2 = (ExperimentSummary)list.get(1);
+            Assert.assertTrue(exp1.getCreationTime()-exp2.getCreationTime() > 0);
+
+        } catch (RegistryException e) {
+            e.printStackTrace();
+            Assert.fail();
+        } catch (ApplicationSettingsException e) {
+            e.printStackTrace();
+        }
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/pom.xml
----------------------------------------------------------------------
diff --git a/modules/registry/pom.xml b/modules/registry/pom.xml
index 72020a2..a3879fc 100644
--- a/modules/registry/pom.xml
+++ b/modules/registry/pom.xml
@@ -32,6 +32,7 @@
             <modules>
                 <module>registry-cpi</module>
                 <module>airavata-jpa-registry</module>
+                <module>airavata-mongo-registry</module>
                 <!--<module>jpa-gen</module>-->
             </modules>
         </profile>


Mime
View raw message