[ 
https://issues.apache.org/jira/browse/AIRAVATA-2619?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16434174#comment-16434174
 ] 

ASF GitHub Bot commented on AIRAVATA-2619:
------------------------------------------

DImuthuUpe commented on a change in pull request #182: [AIRAVATA-2619] 
Refactoring App Catalog implementation - StorageResource
URL: https://github.com/apache/airavata/pull/182#discussion_r180819055
 
 

 ##########
 File path: 
modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/appcatalog/StorageResourceRepositoryTest.java
 ##########
 @@ -0,0 +1,148 @@
+/*
+ * 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.registry.core.repositories.appcatalog;
+
+import 
org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription;
+import org.apache.airavata.model.data.movement.*;
+import org.apache.airavata.registry.core.repositories.util.Initialize;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Created by skariyat on 3/13/18.
+ */
+public class StorageResourceRepositoryTest {
+
+    private static Initialize initialize;
+    private StorageResourceRepository storageResourceRepository;
+    private static final Logger logger = 
LoggerFactory.getLogger(StorageResourceRepository.class);
+
+    @Before
+    public void setUp() {
+        try {
+            initialize = new Initialize("appcatalog-derby.sql");
+            initialize.initializeDB();
+            storageResourceRepository = new StorageResourceRepository();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+        }
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        System.out.println("********** TEAR DOWN ************");
+        initialize.stopDerbyServer();
+    }
+
+    @Test
+    public void StorageResourceRepositoryTest() throws AppCatalogException {
+
+        StorageResourceDescription description = new 
StorageResourceDescription();
+
+        description.setHostName("localhost");
+        description.setEnabled(true);
+        description.setStorageResourceDescription("testDescription");
+
+
+        String scpDataMoveId = addSCPDataMovement();
+        System.out.println("**** SCP DataMoveId****** :" + scpDataMoveId);
+        String gridFTPDataMoveId = addGridFTPDataMovement();
+        System.out.println("**** grid FTP DataMoveId****** :" + 
gridFTPDataMoveId);
+
+        List<DataMovementInterface> dataMovementInterfaces = new 
ArrayList<DataMovementInterface>();
+        DataMovementInterface scpInterface = new DataMovementInterface();
+        scpInterface.setDataMovementInterfaceId(scpDataMoveId);
+        scpInterface.setDataMovementProtocol(DataMovementProtocol.SCP);
+        scpInterface.setPriorityOrder(1);
+
+        DataMovementInterface gridFTPMv = new DataMovementInterface();
+        gridFTPMv.setDataMovementInterfaceId(gridFTPDataMoveId);
+        gridFTPMv.setDataMovementProtocol(DataMovementProtocol.GridFTP);
+        gridFTPMv.setPriorityOrder(2);
+
+        dataMovementInterfaces.add(scpInterface);
+        dataMovementInterfaces.add(gridFTPMv);
+        description.setDataMovementInterfaces(dataMovementInterfaces);
+
+        String resourceId = 
storageResourceRepository.addStorageResource(description);
+        StorageResourceDescription storageResourceDescription = null;
+
+        if (storageResourceRepository.isExists(resourceId)) {
+            storageResourceDescription = 
storageResourceRepository.getStorageResource(resourceId);
+            
assertTrue(storageResourceDescription.getHostName().equals("localhost"));
+            
assertTrue(storageResourceDescription.getStorageResourceDescription().equals("testDescription"));
+            List<DataMovementInterface> movementInterfaces = 
storageResourceDescription.getDataMovementInterfaces();
+            if (movementInterfaces != null && !movementInterfaces.isEmpty()){
+                for (DataMovementInterface dataMovementInterface : 
movementInterfaces){
+                    System.out.println("Data Movement Interface Id :" + 
dataMovementInterface.getDataMovementInterfaceId());
+                    System.out.println("Data Movement Protocol :" + 
dataMovementInterface.getDataMovementProtocol().toString());
+                }
+            }
+        }
+
+        description.setHostName("localhost2");
+        storageResourceRepository.updateStorageResource(resourceId, 
description);
+        if (storageResourceRepository.isStorageResourceExists(resourceId)) {
+            storageResourceDescription = 
storageResourceRepository.getStorageResource(resourceId);
+            System.out.println("**********Updated Resource name ************* 
: " + storageResourceDescription.getHostName());
+            
assertTrue(storageResourceDescription.getHostName().equals("localhost2"));
+        }
+        assertTrue("Storage resource save successfully", 
storageResourceDescription != null);
+
+
+    }
+
+    public String addSCPDataMovement (){
+        try {
+            SCPDataMovement dataMovement = new SCPDataMovement();
+            dataMovement.setSshPort(22);
+            dataMovement.setSecurityProtocol(SecurityProtocol.SSH_KEYS);
+            return new 
ComputeResourceRepository().addScpDataMovement(dataMovement);
+        }catch (AppCatalogException e) {
 
 Review comment:
   } catch

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Refactoring App Catalog implementation
> --------------------------------------
>
>                 Key: AIRAVATA-2619
>                 URL: https://issues.apache.org/jira/browse/AIRAVATA-2619
>             Project: Airavata
>          Issue Type: Sub-task
>            Reporter: Sachin Kariyattin
>            Assignee: Sachin Kariyattin
>            Priority: Major
>
> The app catalog module contains the following Impl classes.
> {quote}ApplicationDeploymentImpl
>  ApplicationInterfaceImpl
>  ComputeResourceImpl
>  GwyResourceProfileImpl
>  StorageResourceImpl
>  UsrResourceProfileImpl
> {quote}
> This task involves creating a repository class for app catalog and include 
> all the methods from the Impl classes mentioned above. As a modular approach 
> is being followed, to start of, only methods GwyResourceProfileImpl will be 
> considered. So the RegistryServiceHandler methods only with respect to 
> GwyResourceProfileImpl will be modified. Subsequently all methods related to 
> app catalog will be refactored.
> *Progress*:
>  * Implemeted GatewayResourceProfileRepository.
>  * Implemented ComputeResourceRepository.
>  * Implemented StorageResourceRepository.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to