airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject git commit: adding test class to appInterface - AIRAVATA-1305
Date Tue, 01 Jul 2014 20:23:07 GMT
Repository: airavata
Updated Branches:
  refs/heads/master a30f8ae67 -> a460074a7


adding test class to appInterface - AIRAVATA-1305


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

Branch: refs/heads/master
Commit: a460074a709d395595c073fb45a3119947b91210
Parents: a30f8ae
Author: Chathuri Wimalasena <kamalasini@gmail.com>
Authored: Tue Jul 1 16:23:03 2014 -0400
Committer: Chathuri Wimalasena <kamalasini@gmail.com>
Committed: Tue Jul 1 16:23:03 2014 -0400

----------------------------------------------------------------------
 .../data/util/AppCatalogThriftConversion.java   |  10 +-
 .../app/catalog/test/AppInterfaceTest.java      | 134 +++++++++++++++++++
 2 files changed, 139 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/a460074a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/util/AppCatalogThriftConversion.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/util/AppCatalogThriftConversion.java
b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/util/AppCatalogThriftConversion.java
index 77ef37a..5c1e30a 100644
--- a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/util/AppCatalogThriftConversion.java
+++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/util/AppCatalogThriftConversion.java
@@ -311,8 +311,8 @@ public class AppCatalogThriftConversion {
         description.setApplicationInterfaceId(resource.getInterfaceId());
         description.setApplicationName(resource.getAppName());
 
-        AppModuleResource appModuleResource = new AppModuleResource();
-        List<Resource> appModules = appModuleResource.get(AbstractResource.AppModuleMappingConstants.INTERFACE_ID,
resource.getInterfaceId());
+        AppModuleMappingResource appModuleMappingResource = new AppModuleMappingResource();
+        List<Resource> appModules = appModuleMappingResource.get(AbstractResource.AppModuleMappingConstants.INTERFACE_ID,
resource.getInterfaceId());
         if (appModules != null && !appModules.isEmpty()){
             description.setApplicationModules(getAppModuleIds(appModules));
         }
@@ -331,10 +331,10 @@ public class AppCatalogThriftConversion {
         return description;
     }
 
-    public static List<String> getAppModuleIds (List<Resource> appModules){
+    public static List<String> getAppModuleIds (List<Resource> appModuleMappings){
         List<String> modules = new ArrayList<String>();
-        for (Resource resource : appModules){
-            modules.add(((AppModuleResource)resource).getModuleId());
+        for (Resource resource : appModuleMappings){
+            modules.add(((AppModuleMappingResource)resource).getModuleId());
         }
         return modules;
     }

http://git-wip-us.apache.org/repos/asf/airavata/blob/a460074a/modules/app-catalog/app-catalog-data/src/test/java/org/apache/airavata/app/catalog/test/AppInterfaceTest.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/test/java/org/apache/airavata/app/catalog/test/AppInterfaceTest.java
b/modules/app-catalog/app-catalog-data/src/test/java/org/apache/airavata/app/catalog/test/AppInterfaceTest.java
new file mode 100644
index 0000000..78ef867
--- /dev/null
+++ b/modules/app-catalog/app-catalog-data/src/test/java/org/apache/airavata/app/catalog/test/AppInterfaceTest.java
@@ -0,0 +1,134 @@
+/*
+ *
+ * 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.app.catalog.test;
+
+import org.airavata.appcatalog.cpi.AppCatalog;
+import org.airavata.appcatalog.cpi.AppCatalogException;
+import org.airavata.appcatalog.cpi.ApplicationInterface;
+import org.apache.aiaravata.application.catalog.data.impl.AppCatalogFactory;
+import org.apache.airavata.app.catalog.test.util.Initialize;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule;
+import org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription;
+import org.apache.airavata.model.appcatalog.appinterface.DataType;
+import org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType;
+import org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.assertTrue;
+
+public class AppInterfaceTest {
+    private static Initialize initialize;
+    private static AppCatalog appcatalog;
+
+    @Before
+    public void setUp() {
+        try {
+            AiravataUtils.setExecutionAsServer();
+            initialize = new Initialize("appcatalog-derby.sql");
+            initialize.initializeDB();
+            appcatalog = AppCatalogFactory.getAppCatalog();
+        } catch (AppCatalogException e) {
+            e.printStackTrace();
+        }
+    }
+
+    @AfterClass
+    public static void tearDownAfterClass() throws Exception {
+        initialize.stopDerbyServer();
+    }
+
+    @Test
+    public void testAppInterface(){
+        try {
+            ApplicationInterface appInterface = appcatalog.getApplicationInterface();
+
+            ApplicationInterfaceDescription description = new ApplicationInterfaceDescription();
+            String wrfModuleId = addAppModule("WRF");
+            String amberModuleId = addAppModule("AMBER");
+            List<String> modules = new ArrayList<String>();
+            modules.add(wrfModuleId);
+            modules.add(amberModuleId);
+            InputDataObjectType appInput1 = createAppInput("input1", "input1", DataType.STRING);
+            InputDataObjectType appInput2 = createAppInput("input2", "input2", DataType.INTEGER);
+            List<InputDataObjectType> inputs = new ArrayList<InputDataObjectType>();
+            inputs.add(appInput1);
+            inputs.add(appInput2);
+            OutputDataObjectType output1 = createAppOutput("output1", "", DataType.STRING);
+            OutputDataObjectType output2 = createAppOutput("output2", "", DataType.STRING);
+            List<OutputDataObjectType> outputs = new ArrayList<OutputDataObjectType>();
+            outputs.add(output1);
+            outputs.add(output2);
+            description.setApplicationName("testApplication");
+            description.setApplicationModules(modules);
+            description.setApplicationInputs(inputs);
+            description.setApplicationOutputs(outputs);
+            String appID = appInterface.addApplicationInterface(description);
+            System.out.println("********** application id ************* : " + appID);
+            ApplicationInterfaceDescription ainterface = null;
+            if (appInterface.isApplicationInterfaceExists(appID)){
+                ainterface = appInterface.getApplicationInterface(appID);
+                System.out.println("********** application name ************* : " + ainterface.getApplicationName());
+            }
+            assertTrue("App interface saved successfully", ainterface != null);
+
+        }catch (AppCatalogException e) {
+            e.printStackTrace();
+        }
+
+    }
+
+    public String addAppModule (String moduleName){
+        try {
+            ApplicationModule module = new ApplicationModule();
+            module.setAppModuleName(moduleName);
+            module.setAppModuleVersion("1.0.0");
+            module.setAppModuleDescription("WeatherForcast");
+            return appcatalog.getApplicationInterface().addApplicationModule(module);
+        } catch (AppCatalogException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    public InputDataObjectType createAppInput (String inputName, String value, DataType type
){
+        InputDataObjectType input = new InputDataObjectType();
+        input.setName(inputName);
+        input.setValue(value);
+        input.setType(type);
+        input.setApplicationArguement("test arg");
+        return input;
+    }
+
+    public OutputDataObjectType createAppOutput (String inputName, String value, DataType
type ){
+        OutputDataObjectType outputDataObjectType = new OutputDataObjectType();
+        outputDataObjectType.setName(inputName);
+        outputDataObjectType.setValue(value);
+        outputDataObjectType.setType(type);
+        return outputDataObjectType;
+    }
+}


Mime
View raw message