airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From machris...@apache.org
Subject [airavata] branch develop updated: AIRAVATA-2839 Removing validation
Date Fri, 20 Jul 2018 18:13:58 GMT
This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata.git


The following commit(s) were added to refs/heads/develop by this push:
     new ca4d613  AIRAVATA-2839 Removing validation
ca4d613 is described below

commit ca4d613ddb114f5502f03eaf6736104d7b4f415e
Author: Marcus Christie <machristie@apache.org>
AuthorDate: Fri Jul 20 14:08:46 2018 -0400

    AIRAVATA-2839 Removing validation
    
    Changes in AIRAVATA-2840 will require GroupResourceProfiles provide
    their own allocation numbers and credential tokens.
---
 .../appcatalog/GroupResourceProfileRepository.java |   2 -
 .../appcatalog/GrpComputePrefRepository.java       |  30 --
 .../appcatalog/GrpComputePrefRepositoryTest.java   | 440 ---------------------
 3 files changed, 472 deletions(-)

diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GroupResourceProfileRepository.java
b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GroupResourceProfileRepository.java
index 04881dd..3c9a401 100644
--- a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GroupResourceProfileRepository.java
+++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GroupResourceProfileRepository.java
@@ -56,9 +56,7 @@ public class GroupResourceProfileRepository extends AppCatAbstractRepository<Gro
 
     private void updateChildren(GroupResourceProfile groupResourceProfile, String groupResourceProfileId)
{
         if (groupResourceProfile.getComputePreferences() != null) {
-            GrpComputePrefRepository grpComputePrefRepository = new GrpComputePrefRepository();
             for (GroupComputeResourcePreference groupComputeResourcePreference: groupResourceProfile.getComputePreferences())
{
-                grpComputePrefRepository.validateGroupComputeResourcePreference(groupComputeResourcePreference,
groupResourceProfile.getGatewayId());
                 groupComputeResourcePreference.setGroupResourceProfileId(groupResourceProfileId);
                 if (groupComputeResourcePreference.getGroupSSHAccountProvisionerConfigs()
!= null) {
                     groupComputeResourcePreference.getGroupSSHAccountProvisionerConfigs().forEach(gssh
-> gssh.setGroupResourceProfileId(groupResourceProfileId));
diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GrpComputePrefRepository.java
b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GrpComputePrefRepository.java
index b9c80cd..a9ef6a3 100644
--- a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GrpComputePrefRepository.java
+++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GrpComputePrefRepository.java
@@ -19,13 +19,9 @@
  */
 package org.apache.airavata.registry.core.repositories.appcatalog;
 
-import org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference;
 import org.apache.airavata.model.appcatalog.groupresourceprofile.GroupComputeResourcePreference;
-import org.apache.airavata.model.appcatalog.groupresourceprofile.GroupResourceProfile;
-import org.apache.airavata.registry.core.entities.appcatalog.ComputeResourcePreferencePK;
 import org.apache.airavata.registry.core.entities.appcatalog.GroupComputeResourcePrefEntity;
 import org.apache.airavata.registry.core.entities.appcatalog.GroupComputeResourcePrefPK;
-import org.apache.commons.lang3.StringUtils;
 
 /**
  * Created by skariyat on 2/10/18.
@@ -35,30 +31,4 @@ public class GrpComputePrefRepository extends AppCatAbstractRepository<GroupComp
     public GrpComputePrefRepository() {
         super(GroupComputeResourcePreference.class, GroupComputeResourcePrefEntity.class);
     }
-
-    public void validateGroupComputeResourcePreference(GroupComputeResourcePreference groupComputeResourcePreference,
String gatewayId) {
-        final String computeResourceId = groupComputeResourcePreference.getComputeResourceId();
-        final ComputeResourcePrefRepository computeResourcePrefRepository = new ComputeResourcePrefRepository();
-        ComputeResourcePreference computeResourcePreference = computeResourcePrefRepository.get(new
ComputeResourcePreferencePK(gatewayId, computeResourceId));
-        if (computeResourcePreference != null) {
-            final String loginUserName = groupComputeResourcePreference.getLoginUserName();
-            boolean loginUserNameDiffers = StringUtils.isNotBlank(loginUserName) &&
!loginUserName.equals(computeResourcePreference.getLoginUserName());
-            boolean allocationProjectNumberNotBlankUsingSameLoginUserName = StringUtils.isNotBlank(groupComputeResourcePreference.getAllocationProjectNumber())
&& StringUtils.isNotBlank(computeResourcePreference.getLoginUserName());
-            // Either loginUserName must differ from the corresponding ComputeResourcePreference
-            // or allocationProjectNumber should not be blank if using login credentials
from computeResourcePreference
-            if (!loginUserNameDiffers && !allocationProjectNumberNotBlankUsingSameLoginUserName)
{
-                throw new RuntimeException("loginUserName must differ from ComputeResourcePreference
or " +
-                        "allocationProjectNumber should not be blank. GroupResourceProfile
"
-                        + groupComputeResourcePreference.getGroupResourceProfileId()
-                        + " for compute resource " + computeResourceId);
-            }
-        }
-    }
-
-    @Override
-    public GroupComputeResourcePreference update(GroupComputeResourcePreference computeResourcePreference)
{
-        GroupResourceProfile groupResourceProfile = (new GroupResourceProfileRepository()).getGroupResourceProfile(computeResourcePreference.getGroupResourceProfileId());
-        validateGroupComputeResourcePreference(computeResourcePreference, groupResourceProfile.getGatewayId());
-        return super.update(computeResourcePreference);
-    }
 }
diff --git a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/appcatalog/GrpComputePrefRepositoryTest.java
b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/appcatalog/GrpComputePrefRepositoryTest.java
deleted file mode 100644
index d7a1d79..0000000
--- a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/appcatalog/GrpComputePrefRepositoryTest.java
+++ /dev/null
@@ -1,440 +0,0 @@
-/*
- * 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.computeresource.ComputeResourceDescription;
-import org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference;
-import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile;
-import org.apache.airavata.model.appcatalog.groupresourceprofile.GroupComputeResourcePreference;
-import org.apache.airavata.model.appcatalog.groupresourceprofile.GroupResourceProfile;
-import org.apache.airavata.registry.core.repositories.common.TestBase;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class GrpComputePrefRepositoryTest extends TestBase {
-    private static final Logger logger = LoggerFactory.getLogger(ComputeResourceRepository.class);
-    private final GrpComputePrefRepository grpComputePrefRepository = new GrpComputePrefRepository();
-    private final ComputeResourceRepository computeResourceRepository = new ComputeResourceRepository();
-    private final GwyResourceProfileRepository gwyResourceProfileRepository = new GwyResourceProfileRepository();
-    private final GroupResourceProfileRepository groupResourceProfileRepository = new GroupResourceProfileRepository();
-
-    public GrpComputePrefRepositoryTest() {
-        super(Database.APP_CATALOG);
-    }
-
-    @Test
-    public void testGwyNoLoginUserNameAndGroupComputePrefNoLoginUserNameFailsValidation()
throws AppCatalogException {
-
-        ComputeResourceDescription description = new ComputeResourceDescription();
-        description.setHostName("test-compute-hostname");
-        String computeResourceId = computeResourceRepository.addComputeResource(description);
-        description.setComputeResourceId(computeResourceId);
-
-        final String gatewayId = "test-gateway-id";
-        GatewayResourceProfile gatewayResourceProfile = new GatewayResourceProfile();
-        gatewayResourceProfile.setGatewayID(gatewayId);
-        ComputeResourcePreference computeResourcePreference = new ComputeResourcePreference();
-        computeResourcePreference.setComputeResourceId(computeResourceId);
-        gatewayResourceProfile.addToComputeResourcePreferences(computeResourcePreference);
-
-        gwyResourceProfileRepository.addGatewayResourceProfile(gatewayResourceProfile);
-
-        GroupComputeResourcePreference groupComputeResourcePreference = new GroupComputeResourcePreference();
-        groupComputeResourcePreference.setComputeResourceId(computeResourceId);
-
-        try {
-            grpComputePrefRepository.validateGroupComputeResourcePreference(groupComputeResourcePreference,
gatewayId);
-            Assert.fail("Should have failed validation");
-        } catch (Exception e) {
-        }
-
-        gwyResourceProfileRepository.removeComputeResourcePreferenceFromGateway(gatewayId,
computeResourceId);
-        gwyResourceProfileRepository.removeGatewayResourceProfile(gatewayId);
-        computeResourceRepository.removeComputeResource(computeResourceId);
-    }
-
-    @Test
-    public void testGwyNoLoginUserNameAndGroupComputePrefHasLoginUserNamePassesValidation()
throws AppCatalogException {
-
-        ComputeResourceDescription description = new ComputeResourceDescription();
-        description.setHostName("test-compute-hostname");
-        String computeResourceId = computeResourceRepository.addComputeResource(description);
-        description.setComputeResourceId(computeResourceId);
-
-        final String gatewayId = "test-gateway-id";
-        final String loginUserName = "test-login-username";
-        GatewayResourceProfile gatewayResourceProfile = new GatewayResourceProfile();
-        gatewayResourceProfile.setGatewayID(gatewayId);
-        ComputeResourcePreference computeResourcePreference = new ComputeResourcePreference();
-        computeResourcePreference.setComputeResourceId(computeResourceId);
-        gatewayResourceProfile.addToComputeResourcePreferences(computeResourcePreference);
-
-        gwyResourceProfileRepository.addGatewayResourceProfile(gatewayResourceProfile);
-
-        GroupComputeResourcePreference groupComputeResourcePreference = new GroupComputeResourcePreference();
-        groupComputeResourcePreference.setComputeResourceId(computeResourceId);
-        groupComputeResourcePreference.setLoginUserName(loginUserName);
-
-        try {
-            grpComputePrefRepository.validateGroupComputeResourcePreference(groupComputeResourcePreference,
gatewayId);
-        } catch (Exception e) {
-            Assert.fail("Should have passed validation");
-        }
-
-        gwyResourceProfileRepository.removeComputeResourcePreferenceFromGateway(gatewayId,
computeResourceId);
-        gwyResourceProfileRepository.removeGatewayResourceProfile(gatewayId);
-        computeResourceRepository.removeComputeResource(computeResourceId);
-    }
-
-    @Test
-    public void testGwyNoLoginUserNameAndGroupComputePrefNoLoginUserNameHasAllocationNumberFailsValidation()
throws AppCatalogException {
-
-        ComputeResourceDescription description = new ComputeResourceDescription();
-        description.setHostName("test-compute-hostname");
-        String computeResourceId = computeResourceRepository.addComputeResource(description);
-        description.setComputeResourceId(computeResourceId);
-
-        final String gatewayId = "test-gateway-id";
-        GatewayResourceProfile gatewayResourceProfile = new GatewayResourceProfile();
-        gatewayResourceProfile.setGatewayID(gatewayId);
-        ComputeResourcePreference computeResourcePreference = new ComputeResourcePreference();
-        computeResourcePreference.setComputeResourceId(computeResourceId);
-        gatewayResourceProfile.addToComputeResourcePreferences(computeResourcePreference);
-
-        gwyResourceProfileRepository.addGatewayResourceProfile(gatewayResourceProfile);
-
-        final String allocationProjectNumber = "test-allocation-number";
-        GroupComputeResourcePreference groupComputeResourcePreference = new GroupComputeResourcePreference();
-        groupComputeResourcePreference.setComputeResourceId(computeResourceId);
-        groupComputeResourcePreference.setAllocationProjectNumber(allocationProjectNumber);
-
-        try {
-            grpComputePrefRepository.validateGroupComputeResourcePreference(groupComputeResourcePreference,
gatewayId);
-            Assert.fail("Should have failed validation");
-        } catch (Exception e) {
-        }
-
-        gwyResourceProfileRepository.removeComputeResourcePreferenceFromGateway(gatewayId,
computeResourceId);
-        gwyResourceProfileRepository.removeGatewayResourceProfile(gatewayId);
-        computeResourceRepository.removeComputeResource(computeResourceId);
-    }
-
-    @Test
-    public void testGwyHasLoginUserNameAndGroupComputePrefNoLoginUserNameFailsValidation()
throws AppCatalogException {
-
-        ComputeResourceDescription description = new ComputeResourceDescription();
-        description.setHostName("test-compute-hostname");
-        String computeResourceId = computeResourceRepository.addComputeResource(description);
-        description.setComputeResourceId(computeResourceId);
-
-        final String gatewayId = "test-gateway-id";
-        final String loginUserName = "test-login-username";
-        GatewayResourceProfile gatewayResourceProfile = new GatewayResourceProfile();
-        gatewayResourceProfile.setGatewayID(gatewayId);
-        ComputeResourcePreference computeResourcePreference = new ComputeResourcePreference();
-        computeResourcePreference.setComputeResourceId(computeResourceId);
-        computeResourcePreference.setLoginUserName(loginUserName);
-        gatewayResourceProfile.addToComputeResourcePreferences(computeResourcePreference);
-
-        gwyResourceProfileRepository.addGatewayResourceProfile(gatewayResourceProfile);
-
-        GroupComputeResourcePreference groupComputeResourcePreference = new GroupComputeResourcePreference();
-        groupComputeResourcePreference.setComputeResourceId(computeResourceId);
-
-        try {
-            grpComputePrefRepository.validateGroupComputeResourcePreference(groupComputeResourcePreference,
gatewayId);
-            Assert.fail("Should have failed validation");
-        } catch (Exception e) {
-        }
-
-        gwyResourceProfileRepository.removeComputeResourcePreferenceFromGateway(gatewayId,
computeResourceId);
-        gwyResourceProfileRepository.removeGatewayResourceProfile(gatewayId);
-        computeResourceRepository.removeComputeResource(computeResourceId);
-    }
-
-    @Test
-    public void testGwyHasLoginUserNameAndGroupComputePrefHasSameLoginUserNameFailsValidation()
throws AppCatalogException {
-
-        ComputeResourceDescription description = new ComputeResourceDescription();
-        description.setHostName("test-compute-hostname");
-        String computeResourceId = computeResourceRepository.addComputeResource(description);
-        description.setComputeResourceId(computeResourceId);
-
-        final String gatewayId = "test-gateway-id";
-        final String loginUserName = "test-login-username";
-        GatewayResourceProfile gatewayResourceProfile = new GatewayResourceProfile();
-        gatewayResourceProfile.setGatewayID(gatewayId);
-        ComputeResourcePreference computeResourcePreference = new ComputeResourcePreference();
-        computeResourcePreference.setComputeResourceId(computeResourceId);
-        computeResourcePreference.setLoginUserName(loginUserName);
-        gatewayResourceProfile.addToComputeResourcePreferences(computeResourcePreference);
-
-        gwyResourceProfileRepository.addGatewayResourceProfile(gatewayResourceProfile);
-
-        GroupComputeResourcePreference groupComputeResourcePreference = new GroupComputeResourcePreference();
-        groupComputeResourcePreference.setComputeResourceId(computeResourceId);
-        groupComputeResourcePreference.setLoginUserName(loginUserName);
-        Assert.assertEquals(groupComputeResourcePreference.getLoginUserName(), computeResourcePreference.getLoginUserName());
-
-        try {
-            grpComputePrefRepository.validateGroupComputeResourcePreference(groupComputeResourcePreference,
gatewayId);
-            Assert.fail("Should have failed validation");
-        } catch (Exception e) {
-        }
-
-        gwyResourceProfileRepository.removeComputeResourcePreferenceFromGateway(gatewayId,
computeResourceId);
-        gwyResourceProfileRepository.removeGatewayResourceProfile(gatewayId);
-        computeResourceRepository.removeComputeResource(computeResourceId);
-    }
-
-    @Test
-    public void testGwyHasLoginUserNameAndGroupComputePrefNoLoginUserNameHasAllocationNumberPassesValidation()
throws AppCatalogException {
-
-        ComputeResourceDescription description = new ComputeResourceDescription();
-        description.setHostName("test-compute-hostname");
-        String computeResourceId = computeResourceRepository.addComputeResource(description);
-        description.setComputeResourceId(computeResourceId);
-
-        final String gatewayId = "test-gateway-id";
-        final String loginUserName = "test-login-username";
-        GatewayResourceProfile gatewayResourceProfile = new GatewayResourceProfile();
-        gatewayResourceProfile.setGatewayID(gatewayId);
-        ComputeResourcePreference computeResourcePreference = new ComputeResourcePreference();
-        computeResourcePreference.setComputeResourceId(computeResourceId);
-        computeResourcePreference.setLoginUserName(loginUserName);
-        gatewayResourceProfile.addToComputeResourcePreferences(computeResourcePreference);
-
-        gwyResourceProfileRepository.addGatewayResourceProfile(gatewayResourceProfile);
-
-        final String allocationProjectNumber = "test-allocation-project-number";
-        GroupComputeResourcePreference groupComputeResourcePreference = new GroupComputeResourcePreference();
-        groupComputeResourcePreference.setComputeResourceId(computeResourceId);
-        groupComputeResourcePreference.setAllocationProjectNumber(allocationProjectNumber);
-
-        try {
-            grpComputePrefRepository.validateGroupComputeResourcePreference(groupComputeResourcePreference,
gatewayId);
-        } catch (Exception e) {
-            Assert.fail("Should have passed validation");
-        }
-
-        gwyResourceProfileRepository.removeComputeResourcePreferenceFromGateway(gatewayId,
computeResourceId);
-        gwyResourceProfileRepository.removeGatewayResourceProfile(gatewayId);
-        computeResourceRepository.removeComputeResource(computeResourceId);
-    }
-
-    @Test
-    public void testGwyHasLoginUserNameAndGroupComputePrefHasSameLoginUserNameHasAllocationNumberPassesValidation()
throws AppCatalogException {
-
-        ComputeResourceDescription description = new ComputeResourceDescription();
-        description.setHostName("test-compute-hostname");
-        String computeResourceId = computeResourceRepository.addComputeResource(description);
-        description.setComputeResourceId(computeResourceId);
-
-        final String gatewayId = "test-gateway-id";
-        final String loginUserName = "test-login-username";
-        GatewayResourceProfile gatewayResourceProfile = new GatewayResourceProfile();
-        gatewayResourceProfile.setGatewayID(gatewayId);
-        ComputeResourcePreference computeResourcePreference = new ComputeResourcePreference();
-        computeResourcePreference.setComputeResourceId(computeResourceId);
-        computeResourcePreference.setLoginUserName(loginUserName);
-        gatewayResourceProfile.addToComputeResourcePreferences(computeResourcePreference);
-
-        gwyResourceProfileRepository.addGatewayResourceProfile(gatewayResourceProfile);
-
-        final String allocationProjectNumber = "test-allocation-project-number";
-        GroupComputeResourcePreference groupComputeResourcePreference = new GroupComputeResourcePreference();
-        groupComputeResourcePreference.setComputeResourceId(computeResourceId);
-        groupComputeResourcePreference.setLoginUserName(loginUserName);
-        groupComputeResourcePreference.setAllocationProjectNumber(allocationProjectNumber);
-        Assert.assertEquals(groupComputeResourcePreference.getLoginUserName(), computeResourcePreference.getLoginUserName());
-
-        try {
-            grpComputePrefRepository.validateGroupComputeResourcePreference(groupComputeResourcePreference,
gatewayId);
-        } catch (Exception e) {
-            Assert.fail("Should have passed validation");
-        }
-
-        gwyResourceProfileRepository.removeComputeResourcePreferenceFromGateway(gatewayId,
computeResourceId);
-        gwyResourceProfileRepository.removeGatewayResourceProfile(gatewayId);
-        computeResourceRepository.removeComputeResource(computeResourceId);
-    }
-
-    @Test
-    public void testGwyHasLoginUserNameAndGroupComputePrefHasDifferentLoginUserNameHasAllocationNumberPassesValidation()
throws AppCatalogException {
-
-        ComputeResourceDescription description = new ComputeResourceDescription();
-        description.setHostName("test-compute-hostname");
-        String computeResourceId = computeResourceRepository.addComputeResource(description);
-        description.setComputeResourceId(computeResourceId);
-
-        final String gatewayId = "test-gateway-id";
-        final String loginUserName = "test-login-username";
-        GatewayResourceProfile gatewayResourceProfile = new GatewayResourceProfile();
-        gatewayResourceProfile.setGatewayID(gatewayId);
-        ComputeResourcePreference computeResourcePreference = new ComputeResourcePreference();
-        computeResourcePreference.setComputeResourceId(computeResourceId);
-        computeResourcePreference.setLoginUserName(loginUserName);
-        gatewayResourceProfile.addToComputeResourcePreferences(computeResourcePreference);
-
-        gwyResourceProfileRepository.addGatewayResourceProfile(gatewayResourceProfile);
-
-        final String allocationProjectNumber = "test-allocation-project-number";
-        GroupComputeResourcePreference groupComputeResourcePreference = new GroupComputeResourcePreference();
-        groupComputeResourcePreference.setComputeResourceId(computeResourceId);
-        groupComputeResourcePreference.setLoginUserName("test-login-username2");
-        groupComputeResourcePreference.setAllocationProjectNumber(allocationProjectNumber);
-        Assert.assertNotEquals(groupComputeResourcePreference.getLoginUserName(), computeResourcePreference.getLoginUserName());
-
-        try {
-            grpComputePrefRepository.validateGroupComputeResourcePreference(groupComputeResourcePreference,
gatewayId);
-        } catch (Exception e) {
-            Assert.fail("Should have passed validation");
-        }
-
-        gwyResourceProfileRepository.removeComputeResourcePreferenceFromGateway(gatewayId,
computeResourceId);
-        gwyResourceProfileRepository.removeGatewayResourceProfile(gatewayId);
-        computeResourceRepository.removeComputeResource(computeResourceId);
-    }
-
-    @Test
-    public void testGwyHasLoginUserNameAndGroupComputePrefHasDifferentLoginUserNamePassesValidation()
throws AppCatalogException {
-
-        ComputeResourceDescription description = new ComputeResourceDescription();
-        description.setHostName("test-compute-hostname");
-        String computeResourceId = computeResourceRepository.addComputeResource(description);
-        description.setComputeResourceId(computeResourceId);
-
-        final String gatewayId = "test-gateway-id";
-        final String loginUserName = "test-login-username";
-        GatewayResourceProfile gatewayResourceProfile = new GatewayResourceProfile();
-        gatewayResourceProfile.setGatewayID(gatewayId);
-        ComputeResourcePreference computeResourcePreference = new ComputeResourcePreference();
-        computeResourcePreference.setComputeResourceId(computeResourceId);
-        computeResourcePreference.setLoginUserName(loginUserName);
-        gatewayResourceProfile.addToComputeResourcePreferences(computeResourcePreference);
-
-        gwyResourceProfileRepository.addGatewayResourceProfile(gatewayResourceProfile);
-
-        GroupComputeResourcePreference groupComputeResourcePreference = new GroupComputeResourcePreference();
-        groupComputeResourcePreference.setComputeResourceId(computeResourceId);
-        groupComputeResourcePreference.setLoginUserName("test-login-username2");
-        Assert.assertNotEquals(groupComputeResourcePreference.getLoginUserName(), computeResourcePreference.getLoginUserName());
-
-        try {
-            grpComputePrefRepository.validateGroupComputeResourcePreference(groupComputeResourcePreference,
gatewayId);
-        } catch (Exception e) {
-            Assert.fail("Should have passed validation");
-        }
-
-        gwyResourceProfileRepository.removeComputeResourcePreferenceFromGateway(gatewayId,
computeResourceId);
-        gwyResourceProfileRepository.removeGatewayResourceProfile(gatewayId);
-        computeResourceRepository.removeComputeResource(computeResourceId);
-    }
-
-    @Test
-    public void testCreateCallsValidationAndFailsValidation() throws AppCatalogException
{
-
-        ComputeResourceDescription description = new ComputeResourceDescription();
-        description.setHostName("test-compute-hostname");
-        String computeResourceId = computeResourceRepository.addComputeResource(description);
-        description.setComputeResourceId(computeResourceId);
-
-        final String gatewayId = "test-gateway-id";
-        final String loginUserName = "test-login-username";
-        GatewayResourceProfile gatewayResourceProfile = new GatewayResourceProfile();
-        gatewayResourceProfile.setGatewayID(gatewayId);
-        ComputeResourcePreference computeResourcePreference = new ComputeResourcePreference();
-        computeResourcePreference.setComputeResourceId(computeResourceId);
-        computeResourcePreference.setLoginUserName(loginUserName);
-        gatewayResourceProfile.addToComputeResourcePreferences(computeResourcePreference);
-
-        gwyResourceProfileRepository.addGatewayResourceProfile(gatewayResourceProfile);
-
-        GroupResourceProfile groupResourceProfile = new GroupResourceProfile();
-        groupResourceProfile.setGatewayId(gatewayId);
-        String groupResourceProfileId = groupResourceProfileRepository.addGroupResourceProfile(groupResourceProfile);
-        groupResourceProfile.setGroupResourceProfileId(groupResourceProfileId);
-
-        GroupComputeResourcePreference groupComputeResourcePreference = new GroupComputeResourcePreference();
-        groupComputeResourcePreference.setGroupResourceProfileId(groupResourceProfileId);
-        groupComputeResourcePreference.setComputeResourceId(computeResourceId);
-        groupComputeResourcePreference.setLoginUserName(loginUserName);
-        Assert.assertEquals(groupComputeResourcePreference.getLoginUserName(), computeResourcePreference.getLoginUserName());
-
-        try {
-            grpComputePrefRepository.create(groupComputeResourcePreference);
-            Assert.fail("Should have failed validation");
-        } catch (Exception e) {
-        }
-
-        gwyResourceProfileRepository.removeComputeResourcePreferenceFromGateway(gatewayId,
computeResourceId);
-        gwyResourceProfileRepository.removeGatewayResourceProfile(gatewayId);
-        computeResourceRepository.removeComputeResource(computeResourceId);
-    }
-
-    @Test
-    public void testUpdateCallsValidationAndFailsValidation() throws AppCatalogException
{
-
-        ComputeResourceDescription description = new ComputeResourceDescription();
-        description.setHostName("test-compute-hostname");
-        String computeResourceId = computeResourceRepository.addComputeResource(description);
-        description.setComputeResourceId(computeResourceId);
-
-        final String gatewayId = "test-gateway-id";
-        final String loginUserName = "test-login-username";
-        GatewayResourceProfile gatewayResourceProfile = new GatewayResourceProfile();
-        gatewayResourceProfile.setGatewayID(gatewayId);
-        ComputeResourcePreference computeResourcePreference = new ComputeResourcePreference();
-        computeResourcePreference.setComputeResourceId(computeResourceId);
-        computeResourcePreference.setLoginUserName(loginUserName);
-        gatewayResourceProfile.addToComputeResourcePreferences(computeResourcePreference);
-
-        gwyResourceProfileRepository.addGatewayResourceProfile(gatewayResourceProfile);
-
-        GroupResourceProfile groupResourceProfile = new GroupResourceProfile();
-        groupResourceProfile.setGatewayId(gatewayId);
-        String groupResourceProfileId = groupResourceProfileRepository.addGroupResourceProfile(groupResourceProfile);
-        groupResourceProfile.setGroupResourceProfileId(groupResourceProfileId);
-
-        GroupComputeResourcePreference groupComputeResourcePreference = new GroupComputeResourcePreference();
-        groupComputeResourcePreference.setGroupResourceProfileId(groupResourceProfileId);
-        groupComputeResourcePreference.setComputeResourceId(computeResourceId);
-        groupComputeResourcePreference.setLoginUserName("test-login-username2");
-        Assert.assertNotEquals(groupComputeResourcePreference.getLoginUserName(), computeResourcePreference.getLoginUserName());
-
-        grpComputePrefRepository.create(groupComputeResourcePreference);
-        groupComputeResourcePreference.setLoginUserName(loginUserName);
-        Assert.assertEquals(groupComputeResourcePreference.getLoginUserName(), computeResourcePreference.getLoginUserName());
-
-        try {
-            grpComputePrefRepository.update(groupComputeResourcePreference);
-            Assert.fail("Should have failed validation");
-        } catch (Exception e) {
-        }
-
-        gwyResourceProfileRepository.removeComputeResourcePreferenceFromGateway(gatewayId,
computeResourceId);
-        gwyResourceProfileRepository.removeGatewayResourceProfile(gatewayId);
-        computeResourceRepository.removeComputeResource(computeResourceId);
-    }
-}


Mime
View raw message