summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfig.java102
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigIdentityMapper.java30
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java2
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/CloudConfigTest.java193
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java1
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudConfigTest.java179
-rw-r--r--adapters/mso-adapter-utils/src/test/resources/cloud_config.json11
-rw-r--r--adapters/mso-adapter-utils/src/test/resources/cloud_default_config.json13
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/MsoUtils.groovy27
-rw-r--r--bpmn/MSOCoreBPMN/pom.xml6
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BaseTask.java922
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/internal/VariableNameExtractor.java67
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/internal/VariableNameExtractorTest.java86
-rw-r--r--bpmn/MSORESTClient/pom.xml5
-rw-r--r--mso-catalog-db/pom.xml8
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java42
-rw-r--r--mso-catalog-db/src/main/resources/ServiceToResourceCustomization.hbm.xml2
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java773
18 files changed, 1336 insertions, 1133 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfig.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfig.java
index 0af0e9422b..ef37f9f719 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfig.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfig.java
@@ -7,9 +7,9 @@
* Licensed 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.
@@ -26,6 +26,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Optional;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.ObjectMapper;
@@ -36,8 +37,8 @@ import org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound;
/**
* JavaBean JSON class for a CloudConfig. This bean maps a JSON-format cloud
* configuration file to Java. The CloudConfig contains information about
- * Openstack cloud configurations. It includes:
- * - CloudIdentity objects,representing DCP nodes (Openstack Identity Service)
+ * Openstack cloud configurations. It includes:
+ * - CloudIdentity objects,representing DCP nodes (Openstack Identity Service)
* - CloudSite objects, representing LCP nodes (Openstack Compute & other services)
*
* Note that this is only used to access Cloud Configurations loaded from a JSON
@@ -51,19 +52,17 @@ import org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound;
@JsonRootName("cloud_config")
public class CloudConfig {
- private boolean validCloudConfig = false;
+ private static final String CLOUD_SITE_VERSION = "2.5";
+ private static final String DEFAULT_CLOUD_SITE_ID = "default";
+ private boolean validCloudConfig = false;
+ private static ObjectMapper mapper = new ObjectMapper();
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
+ protected String configFilePath;
+ protected int refreshTimerInMinutes;
@JsonProperty("identity_services")
private Map<String, CloudIdentity> identityServices = new HashMap<>();
@JsonProperty("cloud_sites")
- private Map<String, CloudSite> cloudSites = new HashMap<>();
-
- private static ObjectMapper mapper = new ObjectMapper();
-
- private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
-
- protected String configFilePath;
-
- protected int refreshTimerInMinutes;
+ private Map<String, CloudSite> cloudSites = new HashMap<>();
public CloudConfig() {
mapper.enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE);
@@ -71,18 +70,14 @@ public class CloudConfig {
}
/**
- * Get a Map of all IdentityServices that have been loaded.
- *
- * @return the Map
+ * Get a map of all identity services that have been loaded.
*/
public synchronized Map<String, CloudIdentity> getIdentityServices() {
return identityServices;
}
/**
- * Get a Map of all CloudSites that have been loaded.
- *
- * @return the Map
+ * Get a map of all cloud sites that have been loaded.
*/
public synchronized Map<String, CloudSite> getCloudSites() {
return cloudSites;
@@ -93,7 +88,7 @@ public class CloudConfig {
* against the regions, and if no match is found there, then against
* individual entries to try and find one with a CLLI that matches the ID
* and an AIC version of 2.5.
- *
+ *
* @param id
* the ID to match
* @return a CloudSite, or null of no match found
@@ -104,53 +99,35 @@ public class CloudConfig {
return cloudSites.get(id);
}
// check for id == CLLI now as well
- return getCloudSiteWithClli(id, "2.5");
+ return getCloudSiteWithClli(id);
}
return null;
}
- /**
- * Get a specific CloudSites, based on a CLLI and (optional) version, which
- * will be matched against the aic_version field of the CloudSite.
- *
- * @param clli
- * the CLLI to match
- * @param version
- * the version to match; may be null in which case any version
- * matches
- * @return a CloudSite, or null of no match found
- */
- public synchronized CloudSite getCloudSiteWithClli(String clli, String version) {
- if (clli != null) {
- // New with 1610 - find cloud site called "DEFAULT" - return that
- // object,with the name modified to match what they asked for. We're
- // looping thru the cloud sites anyway - so save off the default one in case we
- // need it.
- CloudSite defaultCloudSite = null;
- for (CloudSite cs : cloudSites.values()) {
- if (cs.getClli() != null && clli.equals(cs.getClli())) {
- if (version == null || version.equals(cs.getAic_version())) {
- return cs;
- }
- } else if ("default".equalsIgnoreCase(cs.getId())) {
- // save it off in case we need it
- defaultCloudSite = cs.clone();
- }
- }
- // If we get here - we didn't find a match - so return the default
- // cloud site
- if (defaultCloudSite != null) {
- defaultCloudSite.setRegionId(clli);
- defaultCloudSite.setId(clli);
- }
+ private CloudSite getCloudSiteWithClli(String clli) {
+ Optional <CloudSite> cloudSiteOptional = cloudSites.values().stream().filter(cs ->
+ cs.getClli() != null && clli.equals(cs.getClli()) && (CLOUD_SITE_VERSION.equals(cs.getAic_version())))
+ .findAny();
+ return cloudSiteOptional.orElse(getDefaultCloudSite(clli));
+ }
+
+ // TODO in future the result will be optional
+ private CloudSite getDefaultCloudSite(String clli) {
+ Optional<CloudSite> cloudSiteOpt = cloudSites.values().stream()
+ .filter(cs -> cs.getId().equalsIgnoreCase(DEFAULT_CLOUD_SITE_ID)).findAny();
+ if (cloudSiteOpt.isPresent()) {
+ CloudSite defaultCloudSite = cloudSiteOpt.get();
+ defaultCloudSite.setRegionId(clli);
+ defaultCloudSite.setId(clli);
return defaultCloudSite;
+ } else {
+ return null;
}
- return null;
}
/**
* Get a specific CloudIdentity, based on an ID.
- *
+ *
* @param id
* the ID to match
* @return a CloudIdentity, or null of no match found
@@ -173,7 +150,7 @@ public class CloudConfig {
configFilePath = configFile;
this.refreshTimerInMinutes = refreshTimer;
this.validCloudConfig=false;
-
+
try {
reader = new FileReader(configFile);
// Parse the JSON input into a CloudConfig
@@ -200,7 +177,7 @@ public class CloudConfig {
}
}
this.validCloudConfig=true;
-
+
} finally {
try {
if (reader != null) {
@@ -227,12 +204,9 @@ public class CloudConfig {
public synchronized CloudConfig clone() {
CloudConfig ccCopy = new CloudConfig();
for (Entry<String, CloudIdentity> e : identityServices.entrySet()) {
-
ccCopy.identityServices.put(e.getKey(), e.getValue().clone());
}
-
for (Entry<String, CloudSite> e : cloudSites.entrySet()) {
-
ccCopy.cloudSites.put(e.getKey(), e.getValue().clone());
}
ccCopy.configFilePath = this.configFilePath;
@@ -290,5 +264,5 @@ public class CloudConfig {
return true;
}
-
+
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigIdentityMapper.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigIdentityMapper.java
deleted file mode 100644
index 9677d0ee1c..0000000000
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigIdentityMapper.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed 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.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.mso.cloud;
-
-/**
- * This interface provides the method signature for mapping registration.
- * All mappings should be registered by the implementing class.
- */
-@FunctionalInterface
-public interface CloudConfigIdentityMapper {
-
- public void registerAllMappings();
-}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java
index fad0c2368b..08ea84d85d 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java
@@ -22,12 +22,10 @@
package org.openecomp.mso.openstack.utils;
import java.io.Serializable;
-import java.rmi.server.ObjID;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/CloudConfigTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/CloudConfigTest.java
deleted file mode 100644
index dd1b396fae..0000000000
--- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/CloudConfigTest.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.adapter_utils.tests;
-
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import java.util.Map;
-import org.openecomp.mso.cloud.CloudConfig;
-import org.openecomp.mso.cloud.CloudConfigFactory;
-import org.openecomp.mso.cloud.CloudIdentity;
-import org.openecomp.mso.cloud.CloudSite;
-import org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound;
-
-/**
- * This class implements test methods of the CloudConfig features.
- */
-public class CloudConfigTest {
-
- private static CloudConfig con;
- private static CloudConfigFactory cloudConfigFactory= new CloudConfigFactory();
-
- public CloudConfigTest () {
-
- }
-
- /**
- * This method is called before any test occurs.
- * It creates a fake tree from scratch
- * @throws MsoCloudIdentityNotFound
- */
- @Before
- public final void prepare () throws MsoCloudIdentityNotFound {
- ClassLoader classLoader = CloudConfigTest.class.getClassLoader();
- String config = classLoader.getResource("cloud_config.json").toString().substring(5);
-
- cloudConfigFactory.initializeCloudConfig(config,1);
- con = cloudConfigFactory.getCloudConfig();
- }
-
- /**
- * This method implements a test for the getCloudConfig method.
- */
- @Test
- public final void testGetCloudConfig () {
- assertNotNull(con);
- }
-
- /**
- * This method implements a test for the getCloudSites method.
- */
- @Test
- public final void testGetCloudSites () {
- Map<String,CloudSite> siteMap = con.getCloudSites();
- assertNotNull(siteMap);
-
- CloudSite site1 = siteMap.get("MT");
- CloudSite site2 = siteMap.get("DAN");
- CloudSite site3 = siteMap.get("MTINJVCC101");
- CloudSite site4 = siteMap.get("MTSNJA4LCP1");
-
- assertEquals (site1.getRegionId(), "regionOne");
- assertEquals (site1.getIdentityServiceId(), "MT_KEYSTONE");
- assertEquals (site2.getRegionId(), "RegionOne");
- assertEquals (site2.getIdentityServiceId(), "DAN_KEYSTONE");
- assertEquals (site3.getRegionId(), "regionTwo");
- assertEquals (site3.getIdentityServiceId(), "MTINJVCC101_DCP");
- assertEquals (site4.getRegionId(), "mtsnjlcp1");
- assertEquals (site4.getIdentityServiceId(), "MTSNJA3DCP1");
- }
-
-
- /**
- * This method implements a test for the getIdentityServices method.
- */
- @Test
- public final void testGetIdentityServices () {
- Map<String,CloudIdentity> identityMap = con.getIdentityServices ();
- assertNotNull(identityMap);
-
- CloudIdentity identity1 = identityMap.get("MT_KEYSTONE");
- CloudIdentity identity2 = identityMap.get("DAN_KEYSTONE");
- CloudIdentity identity3 = identityMap.get("MTINJVCC101_DCP");
- CloudIdentity identity4 = identityMap.get("MTSNJA3DCP1");
-
- assertEquals("john", identity1.getMsoId());
- assertEquals("changeme", identity1.getMsoPass());
- assertEquals("admin", identity1.getAdminTenant());
- assertEquals("_member_", identity1.getMemberRole());
- assertEquals(false, identity1.hasTenantMetadata());
-
- assertEquals("mockId", identity2.getMsoId());
- assertEquals("stack123", identity2.getMsoPass());
- assertEquals("service", identity2.getAdminTenant());
- assertEquals("_member_", identity2.getMemberRole());
- assertEquals(false, identity2.hasTenantMetadata());
-
- assertEquals("mockIdToo", identity3.getMsoId());
- assertEquals("AICG@mm@@2015", identity3.getMsoPass());
- assertEquals("service", identity3.getAdminTenant());
- assertEquals("admin", identity3.getMemberRole());
- assertEquals(true, identity3.hasTenantMetadata());
-
- assertEquals("mockIdToo", identity4.getMsoId());
- assertEquals("2315QRS2015srq", identity4.getMsoPass());
- assertEquals("service", identity4.getAdminTenant());
- assertEquals("admin", identity4.getMemberRole());
- assertEquals(true, identity4.hasTenantMetadata());
-
- }
-
- /**
- * This method implements a test for the getCloudSite method.
- */
- @Test
- public final void testGetCloudSite () {
- CloudSite site1 = con.getCloudSite("MT");
- assertNotNull(site1);
- assertEquals (site1.getRegionId(), "regionOne");
- assertEquals (site1.getIdentityServiceId(), "MT_KEYSTONE");
- }
-
- /**
- * This method implements a test for the getIdentityService method.
- */
- @Test
- public final void testGetIdentityService () {
- CloudIdentity identity1 = con.getIdentityService("MT_KEYSTONE");
- assertNotNull(identity1);
- assertEquals (identity1.getMsoId(), "john");
- assertEquals (identity1.getMsoPass(), "changeme");
- assertEquals (identity1.getAdminTenant(), "admin");
- assertEquals (identity1.getMemberRole(), "_member_");
- assertEquals (identity1.hasTenantMetadata(), false);
-
- CloudIdentity identity2 = con.getIdentityService("Test");
- assertNull(identity2);
- }
-
- @Test (expected = MsoCloudIdentityNotFound.class)
- public final void testLoadWithWrongFile () throws MsoCloudIdentityNotFound {
- ClassLoader classLoader = CloudConfigTest.class.getClassLoader();
- String config = classLoader.getResource("cloud_config_bad.json").toString().substring(5);
-
- cloudConfigFactory.initializeCloudConfig(config,1);
- }
-
- @Test
- public final void testReloadWithWrongFile () {
- ClassLoader classLoader = CloudConfigTest.class.getClassLoader();
- String config = classLoader.getResource("cloud_config_bad.json").toString().substring(5);
-
- try {
- cloudConfigFactory.initializeCloudConfig(config,1);
- Assert.fail("MsoCloudIdentityNotFound was expected");
- } catch (MsoCloudIdentityNotFound e) {
-
- }
- Assert.assertTrue("Should be an empty CloudConfig", cloudConfigFactory.getCloudConfig().getCloudSites().isEmpty());
- Assert.assertTrue("Should be an empty CloudConfig", cloudConfigFactory.getCloudConfig().getIdentityServices().isEmpty());
-
- // Now reload the right config
- config = classLoader.getResource("cloud_config.json").toString().substring(5);
- cloudConfigFactory.changeMsoPropertiesFilePath(config);
- cloudConfigFactory.reloadCloudConfig();
- Assert.assertTrue("Flag valid Config should be true now that the cloud_config is correct", cloudConfigFactory.getCloudConfig().isValidCloudConfig());
-
- }
-
-}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java
index cd96756644..6fd95d5948 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/MsoHeatUtilsTest.java
@@ -25,6 +25,7 @@ import java.util.HashMap;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openecomp.mso.cloud.CloudConfigFactory;
+import org.openecomp.mso.cloud.CloudConfigTest;
import org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound;
import org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound;
import org.openecomp.mso.openstack.exceptions.MsoException;
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudConfigTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudConfigTest.java
new file mode 100644
index 0000000000..a73e4359fc
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloud/CloudConfigTest.java
@@ -0,0 +1,179 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.cloud;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import java.util.Map;
+import org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound;
+
+public class CloudConfigTest {
+
+ private static String cloudConfigJsonFilePath;
+ private static String cloudDefaultConfigJsonFilePath;
+ private static String cloudConfigInvalidJsonFilePath;
+
+ @BeforeClass
+ public static void preparePaths() {
+ ClassLoader classLoader = CloudConfigTest.class.getClassLoader();
+ cloudConfigJsonFilePath = classLoader.getResource("cloud_config.json").getPath();
+ cloudDefaultConfigJsonFilePath = classLoader.getResource("cloud_default_config.json").getPath();
+ cloudConfigInvalidJsonFilePath = classLoader.getResource("cloud_config_bad.json").getPath();
+ }
+
+ private CloudConfig createTestObject(String jsonFilePath) throws MsoCloudIdentityNotFound {
+ CloudConfigFactory cloudConfigFactory = new CloudConfigFactory();
+ cloudConfigFactory.initializeCloudConfig(jsonFilePath, 1);
+ return cloudConfigFactory.getCloudConfig();
+ }
+
+ @Test
+ public void testGetCloudSites() throws MsoCloudIdentityNotFound {
+ CloudConfig con = createTestObject(cloudConfigJsonFilePath);
+ Map<String, CloudSite> siteMap = con.getCloudSites();
+ assertNotNull(siteMap);
+
+ CloudSite site1 = siteMap.get("MT");
+ CloudSite site2 = siteMap.get("DAN");
+ CloudSite site3 = siteMap.get("MTINJVCC101");
+ CloudSite site4 = siteMap.get("MTSNJA4LCP1");
+
+ assertEquals("regionOne", site1.getRegionId());
+ assertEquals("MT_KEYSTONE", site1.getIdentityServiceId());
+ assertEquals("RegionOne", site2.getRegionId());
+ assertEquals("DAN_KEYSTONE", site2.getIdentityServiceId());
+ assertEquals("regionTwo", site3.getRegionId());
+ assertEquals("MTINJVCC101_DCP", site3.getIdentityServiceId());
+ assertEquals("mtsnjlcp1", site4.getRegionId());
+ assertEquals("MTSNJA3DCP1", site4.getIdentityServiceId());
+ }
+
+ @Test
+ public void testGetIdentityServices() throws MsoCloudIdentityNotFound {
+ CloudConfig con = createTestObject(cloudConfigJsonFilePath);
+ Map<String, CloudIdentity> identityMap = con.getIdentityServices();
+ assertNotNull(identityMap);
+
+ CloudIdentity identity1 = identityMap.get("MT_KEYSTONE");
+ CloudIdentity identity2 = identityMap.get("DAN_KEYSTONE");
+ CloudIdentity identity3 = identityMap.get("MTINJVCC101_DCP");
+ CloudIdentity identity4 = identityMap.get("MTSNJA3DCP1");
+
+ assertEquals("john", identity1.getMsoId());
+ assertEquals("changeme", identity1.getMsoPass());
+ assertEquals("admin", identity1.getAdminTenant());
+ assertEquals("_member_", identity1.getMemberRole());
+ assertFalse(identity1.hasTenantMetadata());
+
+ assertEquals("mockId", identity2.getMsoId());
+ assertEquals("stack123", identity2.getMsoPass());
+ assertEquals("service", identity2.getAdminTenant());
+ assertEquals("_member_", identity2.getMemberRole());
+ assertFalse(identity2.hasTenantMetadata());
+
+ assertEquals("mockIdToo", identity3.getMsoId());
+ assertEquals("AICG@mm@@2015", identity3.getMsoPass());
+ assertEquals("service", identity3.getAdminTenant());
+ assertEquals("admin", identity3.getMemberRole());
+ assertTrue(identity3.hasTenantMetadata());
+
+ assertEquals("mockIdToo", identity4.getMsoId());
+ assertEquals("2315QRS2015srq", identity4.getMsoPass());
+ assertEquals("service", identity4.getAdminTenant());
+ assertEquals("admin", identity4.getMemberRole());
+ assertTrue(identity4.hasTenantMetadata());
+ }
+
+ @Test
+ public void cloudSiteIsGotById_when_IdFound() throws MsoCloudIdentityNotFound {
+ CloudConfig con = createTestObject(cloudConfigJsonFilePath);
+ CloudSite cloudSite = con.getCloudSite("MT");
+ assertNotNull(cloudSite);
+ assertEquals("regionOne", cloudSite.getRegionId());
+ assertEquals("MT_KEYSTONE", cloudSite.getIdentityServiceId());
+ }
+
+ @Test
+ public void cloudSiteIsGotByClli_when_IdNotFound() throws MsoCloudIdentityNotFound {
+ CloudConfig con = createTestObject(cloudConfigJsonFilePath);
+ CloudSite cloudSite = con.getCloudSite("CS_clli");
+ assertNotNull(cloudSite);
+ assertEquals("clliRegion", cloudSite.getRegionId());
+ assertEquals("CS_clli", cloudSite.getClli());
+ assertEquals("CS_service", cloudSite.getIdentityServiceId());
+ }
+
+ @Test
+ public void cloudSiteIsGotByDefault_when_IdAndClliNotFound() throws MsoCloudIdentityNotFound {
+ CloudConfig con = createTestObject(cloudDefaultConfigJsonFilePath);
+ CloudSite cloudSite = con.getCloudSite("not_existing_id");
+ assertNotNull(cloudSite);
+ assertEquals("not_existing_id", cloudSite.getId());
+ assertEquals("not_existing_id", cloudSite.getRegionId());
+ }
+
+ @Test
+ public void testGetIdentityService() throws MsoCloudIdentityNotFound {
+ CloudConfig con = createTestObject(cloudConfigJsonFilePath);
+ CloudIdentity identity1 = con.getIdentityService("MT_KEYSTONE");
+ assertNotNull(identity1);
+ assertEquals("john", identity1.getMsoId());
+ assertEquals("changeme", identity1.getMsoPass());
+ assertEquals("admin", identity1.getAdminTenant());
+ assertEquals("_member_", identity1.getMemberRole());
+ assertFalse(identity1.hasTenantMetadata());
+
+ CloudIdentity identity2 = con.getIdentityService("Test");
+ assertNull(identity2);
+ }
+
+ @Test(expected = MsoCloudIdentityNotFound.class)
+ public void testLoadWithWrongFile() throws MsoCloudIdentityNotFound {
+ createTestObject(cloudConfigInvalidJsonFilePath);
+ }
+
+ @Test
+ public void testReloadWithWrongFile() {
+ CloudConfigFactory cloudConfigFactory = new CloudConfigFactory();
+ try {
+ cloudConfigFactory.initializeCloudConfig(cloudConfigInvalidJsonFilePath, 1);
+ Assert.fail("MsoCloudIdentityNotFound was expected");
+ } catch (MsoCloudIdentityNotFound e) {
+
+ }
+ assertTrue("Should be an empty CloudConfig", cloudConfigFactory.getCloudConfig().getCloudSites().isEmpty());
+ assertTrue("Should be an empty CloudConfig",
+ cloudConfigFactory.getCloudConfig().getIdentityServices().isEmpty());
+ // Now reload the right config
+ cloudConfigFactory.changeMsoPropertiesFilePath(cloudConfigJsonFilePath);
+ cloudConfigFactory.reloadCloudConfig();
+ assertTrue("Flag valid Config should be true now that the cloud_config is correct",
+ cloudConfigFactory.getCloudConfig().isValidCloudConfig());
+ }
+
+}
diff --git a/adapters/mso-adapter-utils/src/test/resources/cloud_config.json b/adapters/mso-adapter-utils/src/test/resources/cloud_config.json
index ee3532fe15..ff24633f32 100644
--- a/adapters/mso-adapter-utils/src/test/resources/cloud_config.json
+++ b/adapters/mso-adapter-utils/src/test/resources/cloud_config.json
@@ -44,7 +44,8 @@
"tenant_metadata": true,
"identity_server_type": "KEYSTONE",
"identity_authentication_type": "USERNAME_PASSWORD"
- }
+ },
+ "CS_service": {}
},
"cloud_sites":
@@ -76,8 +77,14 @@
"clli": "MTSNJA4LCP1",
"aic_version": "2.5",
"identity_service_id": "MTSNJA3DCP1"
+ },
+ "CS":
+ {
+ "region_id": "clliRegion",
+ "clli": "CS_clli",
+ "aic_version": "2.5",
+ "identity_service_id": "CS_service"
}
-
}
}
}
diff --git a/adapters/mso-adapter-utils/src/test/resources/cloud_default_config.json b/adapters/mso-adapter-utils/src/test/resources/cloud_default_config.json
new file mode 100644
index 0000000000..35d18e9789
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/resources/cloud_default_config.json
@@ -0,0 +1,13 @@
+{
+ "cloud_config": {
+ "identity_services": {
+ "default_service": {}
+ },
+ "cloud_sites": {
+ "default": {
+ "region_id": "defaultRegion",
+ "identity_service_id": "default_service"
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/MsoUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/MsoUtils.groovy
index 06992455a2..719aeb837f 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/MsoUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/MsoUtils.groovy
@@ -986,4 +986,31 @@ class MsoUtils {
return requestId
}
+
+ /**
+ * Remove all the empty nodes and attributes from the within the given node
+ * @param node
+ * @return true if all empty nodes and attributes were removed.
+ */
+ public boolean cleanNode( Node node ) {
+ node.attributes().with { a ->
+ a.findAll { !it.value }.each { a.remove( it.key ) }
+ }
+ node.children().with { kids ->
+ kids.findAll { it instanceof Node ? !cleanNode( it ) : false }
+ .each { kids.remove( it ) }
+ }
+ node.attributes() || node.children() || node.text()
+ }
+
+ /**
+ *
+ * @param xml
+ * @return String representation of xml after removing the empty nodes and attributes
+ */
+ public String cleanNode(String xmlString) {
+ def xml = new XmlParser(false, false).parseText(xmlString)
+ cleanNode(xml)
+ return XmlUtil.serialize(xml)
+ }
}
diff --git a/bpmn/MSOCoreBPMN/pom.xml b/bpmn/MSOCoreBPMN/pom.xml
index b3eddeda41..6884c1e33b 100644
--- a/bpmn/MSOCoreBPMN/pom.xml
+++ b/bpmn/MSOCoreBPMN/pom.xml
@@ -167,5 +167,11 @@
<artifactId>status-control</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>3.8.0</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BaseTask.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BaseTask.java
index e9da2355e4..77e418d4c3 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BaseTask.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/BaseTask.java
@@ -23,510 +23,432 @@ package org.openecomp.mso.bpmn.core;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.Expression;
import org.camunda.bpm.engine.delegate.JavaDelegate;
+import org.openecomp.mso.bpmn.core.internal.VariableNameExtractor;
/**
* Base class for service tasks.
*/
public class BaseTask implements JavaDelegate {
- /**
- * Get the value of a required field. This method throws
- * MissingInjectedFieldException if the expression is null, and
- * BadInjectedFieldException if the expression evaluates to a null
- * value.
- *
- * @param expression the expression
- * @param execution the execution
- * @param fieldName the field name (for logging and exceptions)
- * @return the field value
- */
- protected Object getField(Expression expression,
- DelegateExecution execution, String fieldName) {
- return getFieldImpl(expression, execution, fieldName, false);
- }
-
- /**
- * Gets the value of an optional field. There are three conditions
- * in which this method returns null:
- * <p>
- * <ol>
- * <li> The expression itself is null (i.e. the field is missing
- * altogether.</li>
- * <li>The expression evaluates to a null value.</li>
- * <li>The expression references a single variable which has not
- * been set.</li>
- * </ol>
- * <p>
- * Examples:<br>
- * Expression ${x} when x is null: return null<br>
- * Expression ${x} when x is unset: return null<br>
- * Expression ${x+y} when x and/or y are unset: exception<br>
- *
- * @param expression the expression
- * @param execution the execution
- * @param fieldName the field name (for logging and exceptions)
- * @return the field value, possibly null
- */
- protected Object getOptionalField(Expression expression,
- DelegateExecution execution, String fieldName) {
- return getFieldImpl(expression, execution, fieldName, true);
- }
-
- /**
- * Get the value of a required output variable field. This method
- * throws MissingInjectedFieldException if the expression is null, and
- * BadInjectedFieldException if the expression produces a null or
- * illegal variable name. Legal variable names contain only letters,
- * numbers, and the underscore character ('_').
- *
- * @param expression the expression
- * @param execution the execution
- * @param fieldName the field name (for logging and exceptions)
- * @return the output variable name
- */
- protected String getOutputField(Expression expression,
- DelegateExecution execution, String fieldName) {
- Object o = getFieldImpl(expression, execution, fieldName, false);
- if (o instanceof String) {
- String variable = (String) o;
- if (!isLegalVariable(variable)) {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), "'" + variable
- + "' is not a legal variable name");
- }
- return variable;
- } else {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), "expected a variable name string"
- + ", got object of type " + o.getClass().getName());
- }
- }
-
- /**
- * Get the value of an optional output variable field. This method
- * throws BadInjectedFieldException if the expression produces an illegal
- * variable name. Legal variable names contain only letters, numbers,
- * and the underscore character ('_').
- *
- * @param expression the expression
- * @param execution the execution
- * @param fieldName the field name (for logging and exceptions)
- * @return the output variable name, possibly null
- */
- protected String getOptionalOutputField(Expression expression,
- DelegateExecution execution, String fieldName) {
- Object o = getFieldImpl(expression, execution, fieldName, true);
- if (o instanceof String) {
- String variable = (String) o;
- if (!isLegalVariable(variable)) {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), "'" + variable
- + "' is not a legal variable name");
- }
- return variable;
- } else if (o == null) {
- return null;
- } else {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), "expected a variable name string"
- + ", got object of type " + o.getClass().getName());
- }
- }
-
- /**
- * Get the value of a required string field. This method throws
- * MissingInjectedFieldException if the expression is null, and
- * BadInjectedFieldException if the expression evaluates to a null
- * value.
- * <p>
- * Note: the result is coerced to a string value, if necessary.
- *
- * @param expression the expression
- * @param execution the execution
- * @param fieldName the field name (for logging and exceptions)
- * @return the field value
- */
- protected String getStringField(Expression expression,
- DelegateExecution execution, String fieldName) {
- Object o = getFieldImpl(expression, execution, fieldName, false);
- if (o instanceof String) {
- return (String) o;
- } else {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), "cannot convert '" + o.toString()
- + "' to Integer");
- }
- }
-
- /**
- * Gets the value of an optional string field. There are three conditions
- * in which this method returns null:
- * <p>
- * <ol>
- * <li> The expression itself is null (i.e. the field is missing
- * altogether.</li>
- * <li>The expression evaluates to a null value.</li>
- * <li>The expression references a single variable which has not
- * been set.</li>
- * </ol>
- * <p>
- * Examples:<br>
- * Expression ${x} when x is null: return null<br>
- * Expression ${x} when x is unset: return null<br>
- * Expression ${x+y} when x and/or y are unset: exception<br>
- * <p>
- * Note: the result is coerced to a string value, if necessary.
- *
- * @param expression the expression
- * @param execution the execution
- * @param fieldName the field name (for logging and exceptions)
- * @return the field value, possibly null
- */
- protected String getOptionalStringField(Expression expression,
- DelegateExecution execution, String fieldName) {
- Object o = getFieldImpl(expression, execution, fieldName, true);
- if (o instanceof String) {
- return (String) o;
- } else if (o == null) {
- return null;
- } else {
- return o.toString();
- }
- }
-
- /**
- * Get the value of a required integer field. This method throws
- * MissingInjectedFieldException if the expression is null, and
- * BadInjectedFieldException if the expression evaluates to a null
- * value or a value that cannot be coerced to an integer.
- *
- * @param expression the expression
- * @param execution the execution
- * @param fieldName the field name (for logging and exceptions)
- * @return the field value
- */
- protected Integer getIntegerField(Expression expression,
- DelegateExecution execution, String fieldName) {
- Object o = getFieldImpl(expression, execution, fieldName, false);
- if (o instanceof Integer) {
- return (Integer) o;
- } else {
- try {
- return Integer.parseInt(o.toString());
- } catch (NumberFormatException e) {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), "cannot convert '" + o.toString()
- + "' to Integer");
- }
- }
- }
-
- /**
- * Gets the value of an optional integer field. There are three conditions
- * in which this method returns null:
- * <p>
- * <ol>
- * <li> The expression itself is null (i.e. the field is missing
- * altogether.</li>
- * <li>The expression evaluates to a null value.</li>
- * <li>The expression references a single variable which has not
- * been set.</li>
- * </ol>
- * <p>
- * Examples:<br>
- * Expression ${x} when x is null: return null<br>
- * Expression ${x} when x is unset: return null<br>
- * Expression ${x+y} when x and/or y are unset: exception<br>
- * <p>
- * Note: the result is coerced to an integer value, if necessary. This
- * method throws BadInjectedFieldException if the result cannot be coerced
- * to an integer.
- *
- * @param expression the expression
- * @param execution the execution
- * @param fieldName the field name (for logging and exceptions)
- * @return the field value, possibly null
- */
- protected Integer getOptionalIntegerField(Expression expression,
- DelegateExecution execution, String fieldName) {
- Object o = getFieldImpl(expression, execution, fieldName, true);
- if (o instanceof Integer) {
- return (Integer) o;
- } else if (o == null) {
- return null;
- } else {
- try {
- return Integer.parseInt(o.toString());
- } catch (NumberFormatException e) {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), "cannot convert '" + o.toString()
- + "' to Integer");
- }
- }
- }
-
- /**
- * Gets the value of an optional long field. There are three conditions
- * in which this method returns null:
- * <p>
- * <ol>
- * <li> The expression itself is null (i.e. the field is missing
- * altogether.</li>
- * <li>The expression evaluates to a null value.</li>
- * <li>The expression references a single variable which has not
- * been set.</li>
- * </ol>
- * <p>
- * Examples:<br>
- * Expression ${x} when x is null: return null<br>
- * Expression ${x} when x is unset: return null<br>
- * Expression ${x+y} when x and/or y are unset: exception<br>
- * <p>
- * Note: the result is coerced to a long value, if necessary. This
- * method throws BadInjectedFieldException if the result cannot be coerced
- * to a long.
- *
- * @param expression the expression
- * @param execution the execution
- * @param fieldName the field name (for logging and exceptions)
- * @return the field value, possibly null
- */
- protected Long getOptionalLongField(Expression expression,
- DelegateExecution execution, String fieldName) {
- Object o = getFieldImpl(expression, execution, fieldName, true);
- if (o instanceof Long) {
- return (Long) o;
- } else if (o == null) {
- return null;
- } else {
- try {
- return Long.parseLong(o.toString());
- } catch (NumberFormatException e) {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), "cannot convert '" + o.toString()
- + "' to Long");
- }
- }
- }
-
- /**
- * Get the value of a required long field. This method throws
- * MissingInjectedFieldException if the expression is null, and
- * BadInjectedFieldException if the expression evaluates to a null
- * value or a value that cannot be coerced to a long.
- *
- * @param expression the expression
- * @param execution the execution
- * @param fieldName the field name (for logging and exceptions)
- * @return the field value
- */
- protected Long getLongField(Expression expression,
- DelegateExecution execution, String fieldName) {
- Object o = getFieldImpl(expression, execution, fieldName, false);
- if (o instanceof Long) {
- return (Long) o;
- } else {
- try {
- return Long.parseLong(o.toString());
- } catch (NumberFormatException e) {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), "cannot convert '" + o.toString()
- + "' to Long");
- }
- }
- }
-
- /**
- * Common implementation for field "getter" methods.
- * @param expression the expression
- * @param execution the execution
- * @param fieldName the field name (for logging and exceptions)
- * @param optional true if the field is optional
- * @return the field value, possibly null
- */
- private Object getFieldImpl(Expression expression,
- DelegateExecution execution, String fieldName, boolean optional) {
- if (expression == null) {
- if (!optional) {
- throw new MissingInjectedFieldException(
- fieldName, getTaskName());
- }
- return null;
- }
-
- Object value;
-
- try {
- value = expression.getValue(execution);
- } catch (Exception e) {
- if (!optional) {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), e.getClass().getSimpleName(), e);
- }
-
- // At this point, we have an exception that occurred while
- // evaluating an expression for an optional field. A common
- // problem is that the expression is a simple reference to a
- // variable which has never been set, e.g. the expression is
- // ${x}. The normal activiti behavior is to throw an exception,
- // but we don't like that, so we have the following workaround,
- // which parses the expression text to see if it is a "simple"
- // variable reference, and if so, returns null. If the
- // expression is anything other than a single variable
- // reference, then an exception is thrown, as it would have
- // been without this workaround.
-
- // Get the expression text so we can parse it
- String s = expression.getExpressionText();
-
-// if (isDebugEnabled(execution)) {
-// logDebug(execution, getTaskName() + " field '" + fieldName
-// + "' expression evaluation failed: " + s);
-// }
-
- int len = s.length();
- int i = 0;
-
- // Skip whitespace
- while (i < len && Character.isWhitespace(s.charAt(i))) {
- i++;
- }
-
- // Next character must be '$'
- if (i == len || s.charAt(i++) != '$') {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), e.getClass().getSimpleName(), e);
- }
-
- // Skip whitespace
- while (i < len && Character.isWhitespace(s.charAt(i))) {
- i++;
- }
-
- // Next character must be '{'
- if (i == len || s.charAt(i++) != '{') {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), e.getClass().getSimpleName(), e);
- }
-
- // Skip whitespace
- while (i < len && Character.isWhitespace(s.charAt(i))) {
- i++;
- }
-
- // Collect the variable name
- StringBuilder variable = new StringBuilder();
- while (i < len && isWordCharacter(s.charAt(i))) {
- variable.append(s.charAt(i));
- i++;
- }
-
- if (variable.length() == 0) {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), e.getClass().getSimpleName(), e);
- }
-
- // Skip whitespace
- while (i < len && Character.isWhitespace(s.charAt(i))) {
- i++;
- }
-
- // Next character must be '}'
- if (i == len || s.charAt(i++) != '}') {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), e.getClass().getSimpleName(), e);
- }
-
- // Skip whitespace
- while (i < len && Character.isWhitespace(s.charAt(i))) {
- i++;
- }
-
- // Must be at end of string
- if (i != len) {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), e.getClass().getSimpleName(), e);
- }
-
-// if (isDebugEnabled(execution)) {
-// logDebug(execution, "Checking if variable '"
-// + variable.toString() + "' exists");
-// }
-
- // If the variable exists then the problem was
- // something else...
- if (execution.hasVariable(variable.toString())) {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), e.getClass().getSimpleName(), e);
- }
-
- // The variable doesn't exist.
-
-// if (isDebugEnabled(execution)) {
-// logDebug(execution, "Variable '" + variable.toString()
-// + "' does not exist [ok]");
-// }
-
- value = null;
- }
-
- if (value == null && !optional) {
- throw new BadInjectedFieldException(
- fieldName, getTaskName(), "required field has null value");
- }
-
- return value;
- }
-
- /**
- * Tests if a character is a "word" character.
- * @param c the character
- * @return true if the character is a "word" character.
- */
- private boolean isWordCharacter(char c) {
- return (Character.isLetterOrDigit(c) || c == '_');
- }
-
- /**
- * Tests if the specified string is a legal flow variable name.
- * @param name the string
- * @return true if the string is a legal flow variable name
- */
- private boolean isLegalVariable(String name) {
- if (name == null) {
- return false;
- }
-
- int len = name.length();
-
- if (len == 0) {
- return false;
- }
-
- char c = name.charAt(0);
-
- if (!Character.isLetter(c) && c != '_') {
- return false;
- }
-
- for (int i = 1; i < len; i++) {
- c = name.charAt(i);
- if (!Character.isLetterOrDigit(c) && c != '_') {
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Returns the name of the task (normally the java class name).
- * @return the name of the task
- */
- public String getTaskName() {
- return getClass().getSimpleName();
- }
-
- @Override
- public void execute(DelegateExecution execution) throws Exception { }
+ /**
+ * Get the value of a required field. This method throws
+ * MissingInjectedFieldException if the expression is null, and
+ * BadInjectedFieldException if the expression evaluates to a null
+ * value.
+ *
+ * @param expression the expression
+ * @param execution the execution
+ * @param fieldName the field name (for logging and exceptions)
+ * @return the field value
+ */
+ protected Object getField(Expression expression,
+ DelegateExecution execution, String fieldName) {
+ return getFieldImpl(expression, execution, fieldName, false);
+ }
+
+ /**
+ * Gets the value of an optional field. There are three conditions
+ * in which this method returns null:
+ * <p>
+ * <ol>
+ * <li> The expression itself is null (i.e. the field is missing
+ * altogether.</li>
+ * <li>The expression evaluates to a null value.</li>
+ * <li>The expression references a single variable which has not
+ * been set.</li>
+ * </ol>
+ * <p>
+ * Examples:<br>
+ * Expression ${x} when x is null: return null<br>
+ * Expression ${x} when x is unset: return null<br>
+ * Expression ${x+y} when x and/or y are unset: exception<br>
+ *
+ * @param expression the expression
+ * @param execution the execution
+ * @param fieldName the field name (for logging and exceptions)
+ * @return the field value, possibly null
+ */
+ protected Object getOptionalField(Expression expression,
+ DelegateExecution execution, String fieldName) {
+ return getFieldImpl(expression, execution, fieldName, true);
+ }
+
+ /**
+ * Get the value of a required output variable field. This method
+ * throws MissingInjectedFieldException if the expression is null, and
+ * BadInjectedFieldException if the expression produces a null or
+ * illegal variable name. Legal variable names contain only letters,
+ * numbers, and the underscore character ('_').
+ *
+ * @param expression the expression
+ * @param execution the execution
+ * @param fieldName the field name (for logging and exceptions)
+ * @return the output variable name
+ */
+ protected String getOutputField(Expression expression,
+ DelegateExecution execution, String fieldName) {
+ Object o = getFieldImpl(expression, execution, fieldName, false);
+ if (o instanceof String) {
+ String variable = (String) o;
+ if (!isLegalVariable(variable)) {
+ throw new BadInjectedFieldException(
+ fieldName, getTaskName(), "'" + variable
+ + "' is not a legal variable name");
+ }
+ return variable;
+ } else {
+ throw new BadInjectedFieldException(
+ fieldName, getTaskName(), "expected a variable name string"
+ + ", got object of type " + o.getClass().getName());
+ }
+ }
+
+ /**
+ * Get the value of an optional output variable field. This method
+ * throws BadInjectedFieldException if the expression produces an illegal
+ * variable name. Legal variable names contain only letters, numbers,
+ * and the underscore character ('_').
+ *
+ * @param expression the expression
+ * @param execution the execution
+ * @param fieldName the field name (for logging and exceptions)
+ * @return the output variable name, possibly null
+ */
+ protected String getOptionalOutputField(Expression expression,
+ DelegateExecution execution, String fieldName) {
+ Object o = getFieldImpl(expression, execution, fieldName, true);
+ if (o instanceof String) {
+ String variable = (String) o;
+ if (!isLegalVariable(variable)) {
+ throw new BadInjectedFieldException(
+ fieldName, getTaskName(), "'" + variable
+ + "' is not a legal variable name");
+ }
+ return variable;
+ } else if (o == null) {
+ return null;
+ } else {
+ throw new BadInjectedFieldException(
+ fieldName, getTaskName(), "expected a variable name string"
+ + ", got object of type " + o.getClass().getName());
+ }
+ }
+
+ /**
+ * Get the value of a required string field. This method throws
+ * MissingInjectedFieldException if the expression is null, and
+ * BadInjectedFieldException if the expression evaluates to a null
+ * value.
+ * <p>
+ * Note: the result is coerced to a string value, if necessary.
+ *
+ * @param expression the expression
+ * @param execution the execution
+ * @param fieldName the field name (for logging and exceptions)
+ * @return the field value
+ */
+ protected String getStringField(Expression expression,
+ DelegateExecution execution, String fieldName) {
+ Object o = getFieldImpl(expression, execution, fieldName, false);
+ if (o instanceof String) {
+ return (String) o;
+ } else {
+ throw new BadInjectedFieldException(
+ fieldName, getTaskName(), "cannot convert '" + o.toString()
+ + "' to Integer");
+ }
+ }
+
+ /**
+ * Gets the value of an optional string field. There are three conditions
+ * in which this method returns null:
+ * <p>
+ * <ol>
+ * <li> The expression itself is null (i.e. the field is missing
+ * altogether.</li>
+ * <li>The expression evaluates to a null value.</li>
+ * <li>The expression references a single variable which has not
+ * been set.</li>
+ * </ol>
+ * <p>
+ * Examples:<br>
+ * Expression ${x} when x is null: return null<br>
+ * Expression ${x} when x is unset: return null<br>
+ * Expression ${x+y} when x and/or y are unset: exception<br>
+ * <p>
+ * Note: the result is coerced to a string value, if necessary.
+ *
+ * @param expression the expression
+ * @param execution the execution
+ * @param fieldName the field name (for logging and exceptions)
+ * @return the field value, possibly null
+ */
+ protected String getOptionalStringField(Expression expression,
+ DelegateExecution execution, String fieldName) {
+ Object o = getFieldImpl(expression, execution, fieldName, true);
+ if (o instanceof String) {
+ return (String) o;
+ } else if (o == null) {
+ return null;
+ } else {
+ return o.toString();
+ }
+ }
+
+ /**
+ * Get the value of a required integer field. This method throws
+ * MissingInjectedFieldException if the expression is null, and
+ * BadInjectedFieldException if the expression evaluates to a null
+ * value or a value that cannot be coerced to an integer.
+ *
+ * @param expression the expression
+ * @param execution the execution
+ * @param fieldName the field name (for logging and exceptions)
+ * @return the field value
+ */
+ protected Integer getIntegerField(Expression expression,
+ DelegateExecution execution, String fieldName) {
+ Object o = getFieldImpl(expression, execution, fieldName, false);
+ if (o instanceof Integer) {
+ return (Integer) o;
+ } else {
+ try {
+ return Integer.parseInt(o.toString());
+ } catch (NumberFormatException e) {
+ throw new BadInjectedFieldException(
+ fieldName, getTaskName(), "cannot convert '" + o.toString()
+ + "' to Integer");
+ }
+ }
+ }
+
+ /**
+ * Gets the value of an optional integer field. There are three conditions
+ * in which this method returns null:
+ * <p>
+ * <ol>
+ * <li> The expression itself is null (i.e. the field is missing
+ * altogether.</li>
+ * <li>The expression evaluates to a null value.</li>
+ * <li>The expression references a single variable which has not
+ * been set.</li>
+ * </ol>
+ * <p>
+ * Examples:<br>
+ * Expression ${x} when x is null: return null<br>
+ * Expression ${x} when x is unset: return null<br>
+ * Expression ${x+y} when x and/or y are unset: exception<br>
+ * <p>
+ * Note: the result is coerced to an integer value, if necessary. This
+ * method throws BadInjectedFieldException if the result cannot be coerced
+ * to an integer.
+ *
+ * @param expression the expression
+ * @param execution the execution
+ * @param fieldName the field name (for logging and exceptions)
+ * @return the field value, possibly null
+ */
+ protected Integer getOptionalIntegerField(Expression expression,
+ DelegateExecution execution, String fieldName) {
+ Object o = getFieldImpl(expression, execution, fieldName, true);
+ if (o instanceof Integer) {
+ return (Integer) o;
+ } else if (o == null) {
+ return null;
+ } else {
+ try {
+ return Integer.parseInt(o.toString());
+ } catch (NumberFormatException e) {
+ throw new BadInjectedFieldException(
+ fieldName, getTaskName(), "cannot convert '" + o.toString()
+ + "' to Integer");
+ }
+ }
+ }
+
+ /**
+ * Gets the value of an optional long field. There are three conditions
+ * in which this method returns null:
+ * <p>
+ * <ol>
+ * <li> The expression itself is null (i.e. the field is missing
+ * altogether.</li>
+ * <li>The expression evaluates to a null value.</li>
+ * <li>The expression references a single variable which has not
+ * been set.</li>
+ * </ol>
+ * <p>
+ * Examples:<br>
+ * Expression ${x} when x is null: return null<br>
+ * Expression ${x} when x is unset: return null<br>
+ * Expression ${x+y} when x and/or y are unset: exception<br>
+ * <p>
+ * Note: the result is coerced to a long value, if necessary. This
+ * method throws BadInjectedFieldException if the result cannot be coerced
+ * to a long.
+ *
+ * @param expression the expression
+ * @param execution the execution
+ * @param fieldName the field name (for logging and exceptions)
+ * @return the field value, possibly null
+ */
+ protected Long getOptionalLongField(Expression expression,
+ DelegateExecution execution, String fieldName) {
+ Object o = getFieldImpl(expression, execution, fieldName, true);
+ if (o instanceof Long) {
+ return (Long) o;
+ } else if (o == null) {
+ return null;
+ } else {
+ try {
+ return Long.parseLong(o.toString());
+ } catch (NumberFormatException e) {
+ throw new BadInjectedFieldException(
+ fieldName, getTaskName(), "cannot convert '" + o.toString()
+ + "' to Long");
+ }
+ }
+ }
+
+ /**
+ * Get the value of a required long field. This method throws
+ * MissingInjectedFieldException if the expression is null, and
+ * BadInjectedFieldException if the expression evaluates to a null
+ * value or a value that cannot be coerced to a long.
+ *
+ * @param expression the expression
+ * @param execution the execution
+ * @param fieldName the field name (for logging and exceptions)
+ * @return the field value
+ */
+ protected Long getLongField(Expression expression,
+ DelegateExecution execution, String fieldName) {
+ Object o = getFieldImpl(expression, execution, fieldName, false);
+ if (o instanceof Long) {
+ return (Long) o;
+ } else {
+ try {
+ return Long.parseLong(o.toString());
+ } catch (NumberFormatException e) {
+ throw new BadInjectedFieldException(
+ fieldName, getTaskName(), "cannot convert '" + o.toString()
+ + "' to Long");
+ }
+ }
+ }
+
+ /**
+ * Common implementation for field "getter" methods.
+ *
+ * @param expression the expression
+ * @param execution the execution
+ * @param fieldName the field name (for logging and exceptions)
+ * @param optional true if the field is optional
+ * @return the field value, possibly null
+ */
+ private Object getFieldImpl(Expression expression,
+ DelegateExecution execution, String fieldName, boolean optional) {
+ if (expression == null) {
+ if (!optional) {
+ throw new MissingInjectedFieldException(
+ fieldName, getTaskName());
+ }
+ return null;
+ }
+
+ Object value = null;
+
+ try {
+ value = expression.getValue(execution);
+ } catch (Exception e) {
+ if (!optional) {
+ throw new BadInjectedFieldException(
+ fieldName, getTaskName(), e.getClass().getSimpleName(), e);
+ }
+
+ // At this point, we have an exception that occurred while
+ // evaluating an expression for an optional field. A common
+ // problem is that the expression is a simple reference to a
+ // variable which has never been set, e.g. the expression is
+ // ${x}. The normal activiti behavior is to throw an exception,
+ // but we don't like that, so we have the following workaround,
+ // which parses the expression text to see if it is a "simple"
+ // variable reference, and if so, returns null. If the
+ // expression is anything other than a single variable
+ // reference, then an exception is thrown, as it would have
+ // been without this workaround.
+
+ // Get the expression text so we can parse it
+ String s = expression.getExpressionText();
+ new VariableNameExtractor(s).extract().ifPresent(name -> {
+ if (execution.hasVariable(name)) {
+ throw new BadInjectedFieldException(
+ fieldName, getTaskName(), e.getClass().getSimpleName(), e);
+ }
+ });
+ }
+
+ if (value == null && !optional) {
+ throw new BadInjectedFieldException(
+ fieldName, getTaskName(), "required field has null value");
+ }
+
+ return value;
+ }
+
+ /**
+ * Tests if a character is a "word" character.
+ *
+ * @param c the character
+ * @return true if the character is a "word" character.
+ */
+ private static boolean isWordCharacter(char c) {
+ return (Character.isLetterOrDigit(c) || c == '_');
+ }
+
+ /**
+ * Tests if the specified string is a legal flow variable name.
+ *
+ * @param name the string
+ * @return true if the string is a legal flow variable name
+ */
+ private boolean isLegalVariable(String name) {
+ if (name == null) {
+ return false;
+ }
+
+ int len = name.length();
+
+ if (len == 0) {
+ return false;
+ }
+
+ char c = name.charAt(0);
+
+ if (!Character.isLetter(c) && c != '_') {
+ return false;
+ }
+
+ for (int i = 1; i < len; i++) {
+ c = name.charAt(i);
+ if (!Character.isLetterOrDigit(c) && c != '_') {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Returns the name of the task (normally the java class name).
+ *
+ * @return the name of the task
+ */
+ public String getTaskName() {
+ return getClass().getSimpleName();
+ }
+
+ @Override
+ public void execute(DelegateExecution execution) throws Exception {
+ }
}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/internal/VariableNameExtractor.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/internal/VariableNameExtractor.java
new file mode 100644
index 0000000000..e1aaba74da
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/internal/VariableNameExtractor.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.bpmn.core.internal;
+
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Extracts variable name from expression if entire expression is just
+ * one variable, for example "${x}".
+ *
+ * Ignores all whitespaces, except inside variable name.
+ *
+ * Examples:
+ * "${x}", extracted variable name is "x"
+ * " ${\t weird_NAME }", extracted variable name is "weird_NAME"
+ * "${incorrect name}", no extracted name
+ * "${two}+${two}", no extracted name
+ */
+public class VariableNameExtractor {
+
+ private static final Pattern VARIABLE_NAME_PATTERN = Pattern
+ .compile("^\\s*\\$\\s*\\{\\s*([a-zA-Z0-9_]+)\\s*\\}\\s*$");
+
+ private final String expression;
+
+
+ /**
+ * Creates new VariableNameExtractor
+ * @param expression expression to be parsed
+ */
+ public VariableNameExtractor(String expression) {
+ this.expression = expression;
+ }
+
+ /**
+ * Extracts variable name from expression given in constructor
+ * @return Optional of variable name, empty if expression wasn't single variable
+ */
+ public Optional<String> extract() {
+ Matcher matcher = VARIABLE_NAME_PATTERN.matcher(expression);
+ if (!matcher.matches()) {
+ return Optional.empty();
+ }
+ return Optional.of(matcher.group(1));
+ }
+
+}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/internal/VariableNameExtractorTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/internal/VariableNameExtractorTest.java
new file mode 100644
index 0000000000..57f479f7cb
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/internal/VariableNameExtractorTest.java
@@ -0,0 +1,86 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.bpmn.core.internal;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.Optional;
+import org.junit.Test;
+
+public class VariableNameExtractorTest {
+
+ @Test
+ public void shouldExtractVariableName() throws Exception {
+ // given
+ String name = "A_different_NAME123";
+ String variable = "${A_different_NAME123}";
+ VariableNameExtractor extractor = new VariableNameExtractor(variable);
+ // when
+ Optional<String> extracted = extractor.extract();
+ // then
+ assertThat(extracted).isPresent().contains(name);
+ }
+
+ @Test
+ public void shouldExtractVariableNameFromWhitespaces() throws Exception {
+ // given
+ String name = "name";
+ String variable = " \n\t$ \n\t{ \n\tname \n\t} \n\t";
+ VariableNameExtractor extractor = new VariableNameExtractor(variable);
+ // when
+ Optional<String> extracted = extractor.extract();
+ // then
+ assertThat(extracted).isPresent().contains(name);
+ }
+
+ @Test
+ public void shouldReturnEmptyIfThereIsMoreThanVariable() throws Exception {
+ // given
+ String variable = "a ${test}";
+ VariableNameExtractor extractor = new VariableNameExtractor(variable);
+ // when
+ Optional<String> extracted = extractor.extract();
+ // then
+ assertThat(extracted).isNotPresent();
+ }
+
+ @Test
+ public void shouldReturnEmptyIfVariableNameIsIncorrect() throws Exception {
+ // given
+ String variable = "${name with space}";
+ VariableNameExtractor extractor = new VariableNameExtractor(variable);
+ // when
+ Optional<String> extracted = extractor.extract();
+ // then
+ assertThat(extracted).isNotPresent();
+ }
+
+ @Test
+ public void shouldReturnEmptyIfTwoVariablesPresent() throws Exception {
+ // given
+ String variable = "${var1} ${var2}";
+ VariableNameExtractor extractor = new VariableNameExtractor(variable);
+ // when
+ Optional<String> extracted = extractor.extract();
+ // then
+ assertThat(extracted).isNotPresent();
+ }
+} \ No newline at end of file
diff --git a/bpmn/MSORESTClient/pom.xml b/bpmn/MSORESTClient/pom.xml
index dead7d02d8..c17015c003 100644
--- a/bpmn/MSORESTClient/pom.xml
+++ b/bpmn/MSORESTClient/pom.xml
@@ -22,11 +22,6 @@
<artifactId>httpmime</artifactId>
<version>4.5</version>
</dependency>
- <dependency>
- <groupId>com.metaparadigm</groupId>
- <artifactId>json-rpc</artifactId>
- <version>1.0</version>
- </dependency>
<dependency>
<groupId>org.mockito</groupId>
diff --git a/mso-catalog-db/pom.xml b/mso-catalog-db/pom.xml
index 8b663c1394..0dc9e348e9 100644
--- a/mso-catalog-db/pom.xml
+++ b/mso-catalog-db/pom.xml
@@ -171,5 +171,11 @@
<artifactId>common</artifactId>
<version>${project.version}</version>
</dependency>
- </dependencies>
+ <dependency>
+ <groupId>org.jmockit</groupId>
+ <artifactId>jmockit</artifactId>
+ <version>1.8</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
</project>
diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java
index dd60bc7d9c..cdde98dd36 100644
--- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java
@@ -155,29 +155,29 @@ public class CatalogDatabase implements Closeable {
* @return A list of HeatTemplate objects
*/
@SuppressWarnings("unchecked")
- public List <HeatTemplate> getAllHeatTemplates () {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get all Heat templates");
+ public List <HeatTemplate> getAllHeatTemplates() {
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get all Heat templates");
String hql = "FROM HeatTemplate";
- Query query = getSession ().createQuery (hql);
+ Query query = getSession().createQuery(hql);
- List <HeatTemplate> result = query.list ();
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllHeatTemplates", null);
+ List <HeatTemplate> result = query.list();
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getAllHeatTemplates", null);
return result;
}
/**
* Fetch a specific Heat Template by ID.
*
- * @param templateId
+ * @param templateId template id
* @return HeatTemplate object or null if none found
*/
@Deprecated
- public HeatTemplate getHeatTemplate (int templateId) {
- long startTime = System.currentTimeMillis ();
+ public HeatTemplate getHeatTemplate(int templateId) {
+ long startTime = System.currentTimeMillis();
LOGGER.debug ("Catalog database - get Heat template with id " + templateId);
- HeatTemplate template = (HeatTemplate) getSession ().get (HeatTemplate.class, templateId);
+ HeatTemplate template = (HeatTemplate) getSession().get(HeatTemplate.class, templateId);
LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplate", null);
return template;
}
@@ -185,31 +185,31 @@ public class CatalogDatabase implements Closeable {
/**
* Return the newest version of a specific Heat Template (queried by Name).
*
- * @param templateName
+ * @param templateName template name
* @return HeatTemplate object or null if none found
*/
- public HeatTemplate getHeatTemplate (String templateName) {
+ public HeatTemplate getHeatTemplate(String templateName) {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get Heat template with name " + templateName);
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get Heat template with name " + templateName);
String hql = "FROM HeatTemplate WHERE templateName = :template_name";
- Query query = getSession ().createQuery (hql);
- query.setParameter ("template_name", templateName);
+ Query query = getSession().createQuery (hql);
+ query.setParameter("template_name", templateName);
@SuppressWarnings("unchecked")
- List <HeatTemplate> resultList = query.list ();
+ List <HeatTemplate> resultList = query.list();
// See if something came back. Name is unique, so
if (resultList.isEmpty ()) {
LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. No template found", "CatalogDB", "getHeatTemplate", null);
return null;
}
- Collections.sort (resultList, new MavenLikeVersioningComparator ());
- Collections.reverse (resultList);
+ Collections.sort(resultList, new MavenLikeVersioningComparator());
+ Collections.reverse(resultList);
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplate", null);
- return resultList.get (0);
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getHeatTemplate", null);
+ return resultList.get(0);
}
/**
diff --git a/mso-catalog-db/src/main/resources/ServiceToResourceCustomization.hbm.xml b/mso-catalog-db/src/main/resources/ServiceToResourceCustomization.hbm.xml
index d806b48b45..cd37fc9a99 100644
--- a/mso-catalog-db/src/main/resources/ServiceToResourceCustomization.hbm.xml
+++ b/mso-catalog-db/src/main/resources/ServiceToResourceCustomization.hbm.xml
@@ -29,11 +29,11 @@
<composite-id>
<key-property name="modelType" type="string" column="MODEL_TYPE" length="20" />
<key-property name="resourceModelCustomizationUUID" type="string" column="RESOURCE_MODEL_CUSTOMIZATION_UUID" length="200" />
+ <key-property name="serviceModelUUID" type="string" column="SERVICE_MODEL_UUID" length="200" />
</composite-id>
<property name="created" type="timestamp" generated="insert" update="false" insert="false" not-null="true">
<column name="CREATION_TIMESTAMP" default="CURRENT_TIMESTAMP"/>
</property>
- <property name="serviceModelUUID" type="string" column="SERVICE_MODEL_UUID" length="200" not-null="true"/>
</class>
</hibernate-mapping>
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java
index a00079d8a9..9b0f120222 100644
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java
+++ b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java
@@ -20,16 +20,59 @@
package org.openecomp.mso.db.catalog.test;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.sql.Connection;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Set;
+import mockit.Mock;
+import mockit.MockUp;
+import org.hibernate.CacheMode;
+import org.hibernate.Criteria;
+import org.hibernate.Filter;
+import org.hibernate.FlushMode;
+import org.hibernate.HibernateException;
+import org.hibernate.IdentifierLoadAccess;
+import org.hibernate.LobHelper;
+import org.hibernate.LockMode;
+import org.hibernate.LockOptions;
+import org.hibernate.NaturalIdLoadAccess;
+import org.hibernate.Query;
+import org.hibernate.ReplicationMode;
+import org.hibernate.SQLQuery;
+import org.hibernate.ScrollMode;
+import org.hibernate.ScrollableResults;
+import org.hibernate.Session;
+import org.hibernate.SessionEventListener;
+import org.hibernate.SessionFactory;
+import org.hibernate.SharedSessionBuilder;
+import org.hibernate.SimpleNaturalIdLoadAccess;
+import org.hibernate.Transaction;
+import org.hibernate.TypeHelper;
+import org.hibernate.UnknownProfileException;
+import org.hibernate.jdbc.ReturningWork;
+import org.hibernate.jdbc.Work;
+import org.hibernate.metamodel.source.annotations.xml.mocker.MockHelper;
+import org.hibernate.procedure.ProcedureCall;
+import org.hibernate.stat.SessionStatistics;
+import org.hibernate.transform.ResultTransformer;
+import org.hibernate.type.Type;
import org.junit.Before;
import org.junit.Test;
import org.openecomp.mso.db.catalog.CatalogDatabase;
@@ -58,268 +101,370 @@ import org.openecomp.mso.db.catalog.utils.RecordNotFoundException;
public class CatalogDatabaseTest {
- CatalogDatabase cd = null;
-
- @Before
- public void setup(){
- cd = CatalogDatabase.getInstance();
- }
- @Test(expected = Exception.class)
- public void getAllHeatTemplatesTestException(){
- List <HeatTemplate> list = cd.getAllHeatTemplates();
- }
-
- @Test(expected = Exception.class)
- public void getHeatTemplateTestException(){
- HeatTemplate ht = cd.getHeatTemplate(10);
- }
-
- @Test(expected = Exception.class)
- public void getHeatTemplateTest2Exception(){
- HeatTemplate ht = cd.getHeatTemplate("heat123");
- }
-
- @Test(expected = Exception.class)
- public void getHeatTemplateTest3Exception(){
- HeatTemplate ht = cd.getHeatTemplate("heat123","v2");
- }
-
- @Test(expected = Exception.class)
- public void getHeatTemplateByArtifactUuidException(){
- HeatTemplate ht = cd.getHeatTemplateByArtifactUuid("123");
- }
-
- @Test(expected = Exception.class)
- public void getHeatTemplateByArtifactUuidRegularQueryException(){
- HeatTemplate ht = cd.getHeatTemplateByArtifactUuidRegularQuery("123");
- }
-
- @Test(expected = Exception.class)
- public void getParametersForHeatTemplateTestException(){
- List<HeatTemplateParam> ht = cd.getParametersForHeatTemplate("123");
- }
-
- @Test(expected = Exception.class)
- public void getHeatEnvironmentByArtifactUuidTestException(){
- HeatEnvironment ht = cd.getHeatEnvironmentByArtifactUuid("123");
- }
-
- @Test(expected = Exception.class)
- public void getServiceByInvariantUUIDTestException(){
- Service ht = cd.getServiceByInvariantUUID("123");
- }
-
- @Test(expected = Exception.class)
- public void getServiceTestException(){
- Service ht = cd.getService("123");
- }
-
- @Test(expected = Exception.class)
- public void getServiceByModelUUIDTestException(){
- Service ht = cd.getServiceByModelUUID("123");
- }
-
- @Test(expected = Exception.class)
- public void getService2TestException(){
- HashMap<String, String> map = new HashMap<>();
- map.put("serviceNameVersionId", "v2");
- Service ht = cd.getService(map, "123");
- }
-
- @Test(expected = Exception.class)
- public void getServiceByModelNameTestException(){
- Service ht = cd.getServiceByModelName("123");
- }
-
- @Test(expected = Exception.class)
- public void getServiceByVersionAndInvariantIdTestException() throws Exception{
- Service ht = cd.getServiceByVersionAndInvariantId("123","tetwe");
- }
-
- @Test(expected = Exception.class)
- public void getServiceRecipeTestException() throws Exception{
- ServiceRecipe ht = cd.getServiceRecipe("123","tetwe");
- }
-
- @Test(expected = Exception.class)
- public void getServiceRecipeByServiceModelUuidTestException() throws Exception{
- ServiceRecipe ht = cd.getServiceRecipeByServiceModelUuid("123","tetwe");
- }
-
- @Test(expected = Exception.class)
- public void getServiceRecipesTestException() throws Exception{
- List<ServiceRecipe> ht = cd.getServiceRecipes("123");
- }
-
- @Test(expected = Exception.class)
- public void getVnfComponentTestException() throws Exception{
- VnfComponent ht = cd.getVnfComponent(123,"vnf");
- }
-
- @Test(expected = Exception.class)
- public void getVnfResourceTestException() throws Exception{
- VnfResource ht = cd.getVnfResource("vnf");
- }
-
- @Test(expected = Exception.class)
- public void getVnfResource2TestException() throws Exception{
- VnfResource ht = cd.getVnfResource("vnf","3992");
- }
-
- @Test(expected = Exception.class)
- public void getVnfResourceByModelCustomizationIdTestException() throws Exception{
- VnfResource ht = cd.getVnfResourceByModelCustomizationId("3992");
- }
-
- @Test(expected = Exception.class)
- public void getServiceRecipeTest2Exception() throws Exception{
- ServiceRecipe ht = cd.getServiceRecipe(1001,"3992");
- }
-
+ CatalogDatabase cd = null;
+
+ @Before
+ public void setup(){
+ cd = CatalogDatabase.getInstance();
+ }
+
+
+ @Test
+ public void getAllHeatTemplatesTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ @Mock
+ public List<HeatTemplate> list() {
+ HeatTemplate heatTemplate = new HeatTemplate();
+ return Arrays.asList(heatTemplate);
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ List <HeatTemplate> list = cd.getAllHeatTemplates();
+ assertEquals(list.size(), 1);
+ }
+
+ @Test
+ public void getHeatTemplateByIdTest(){
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Object get(Class cls, Serializable id) {
+ HeatTemplate heatTemplate = new HeatTemplate();
+ heatTemplate.setAsdcUuid("123-uuid");
+ return heatTemplate;
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ HeatTemplate ht = cd.getHeatTemplate(10);
+ assertEquals("123-uuid", ht.getAsdcUuid());
+ }
+
+ @Test
+ public void getHeatTemplateByNameEmptyListTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ @Mock
+ public List<HeatTemplate> list() {
+ HeatTemplate heatTemplate = new HeatTemplate();
+ return Arrays.asList();
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ HeatTemplate ht = cd.getHeatTemplate("heat123");
+ assertEquals(null, ht);
+ }
+
+ @Test
+ public void getHeatTemplateByNameTest(){
+
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ @Mock
+ public List<HeatTemplate> list() {
+ HeatTemplate heatTemplate1 = new HeatTemplate();
+ heatTemplate1.setAsdcUuid("123-uuid");
+ heatTemplate1.setVersion("1.2");
+ HeatTemplate heatTemplate2 = new HeatTemplate();
+ heatTemplate2.setAsdcUuid("456-uuid");
+ heatTemplate2.setVersion("1.3");
+ return Arrays.asList(heatTemplate1, heatTemplate2);
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+
+ HeatTemplate ht = cd.getHeatTemplate("heat123");
+ assertEquals("456-uuid", ht.getAsdcUuid());
+ }
+
+ @Test(expected = Exception.class)
+ public void getHeatTemplateTest3Exception(){
+ HeatTemplate ht = cd.getHeatTemplate("heat123","v2");
+ }
+
+ @Test(expected = Exception.class)
+ public void getHeatTemplateByArtifactUuidException(){
+ HeatTemplate ht = cd.getHeatTemplateByArtifactUuid("123");
+ }
+
+ @Test(expected = Exception.class)
+ public void getHeatTemplateByArtifactUuidRegularQueryException(){
+ HeatTemplate ht = cd.getHeatTemplateByArtifactUuidRegularQuery("123");
+ }
+
+ @Test(expected = Exception.class)
+ public void getParametersForHeatTemplateTestException(){
+ List<HeatTemplateParam> ht = cd.getParametersForHeatTemplate("123");
+ }
+
+ @Test(expected = Exception.class)
+ public void getHeatEnvironmentByArtifactUuidTestException(){
+ HeatEnvironment ht = cd.getHeatEnvironmentByArtifactUuid("123");
+ }
+
+ @Test(expected = Exception.class)
+ public void getServiceByInvariantUUIDTestException(){
+ Service ht = cd.getServiceByInvariantUUID("123");
+ }
+
+ @Test(expected = Exception.class)
+ public void getServiceTestException(){
+ Service ht = cd.getService("123");
+ }
+
+ @Test(expected = Exception.class)
+ public void getServiceByModelUUIDTestException(){
+ Service ht = cd.getServiceByModelUUID("123");
+ }
+
+ @Test(expected = Exception.class)
+ public void getService2TestException(){
+ HashMap<String, String> map = new HashMap<>();
+ map.put("serviceNameVersionId", "v2");
+ Service ht = cd.getService(map, "123");
+ }
+
+ @Test(expected = Exception.class)
+ public void getServiceByModelNameTestException(){
+ Service ht = cd.getServiceByModelName("123");
+ }
+
+ @Test(expected = Exception.class)
+ public void getServiceByVersionAndInvariantIdTestException() throws Exception{
+ Service ht = cd.getServiceByVersionAndInvariantId("123","tetwe");
+ }
+
+ @Test(expected = Exception.class)
+ public void getServiceRecipeTestException() throws Exception{
+ ServiceRecipe ht = cd.getServiceRecipe("123","tetwe");
+ }
+
+ @Test(expected = Exception.class)
+ public void getServiceRecipeByServiceModelUuidTestException() throws Exception{
+ ServiceRecipe ht = cd.getServiceRecipeByServiceModelUuid("123","tetwe");
+ }
+
+ @Test(expected = Exception.class)
+ public void getServiceRecipesTestException() throws Exception{
+ List<ServiceRecipe> ht = cd.getServiceRecipes("123");
+ }
+
+ @Test(expected = Exception.class)
+ public void getVnfComponentTestException() throws Exception{
+ VnfComponent ht = cd.getVnfComponent(123,"vnf");
+ }
+
+ @Test(expected = Exception.class)
+ public void getVnfResourceTestException() throws Exception{
+ VnfResource ht = cd.getVnfResource("vnf");
+ }
+
+ @Test(expected = Exception.class)
+ public void getVnfResource2TestException() throws Exception{
+ VnfResource ht = cd.getVnfResource("vnf","3992");
+ }
+
+ @Test(expected = Exception.class)
+ public void getVnfResourceByModelCustomizationIdTestException() throws Exception{
+ VnfResource ht = cd.getVnfResourceByModelCustomizationId("3992");
+ }
+
+ @Test(expected = Exception.class)
+ public void getServiceRecipeTest2Exception() throws Exception{
+ ServiceRecipe ht = cd.getServiceRecipe(1001,"3992");
+ }
+
@Test(expected = Exception.class)
public void getVnfResourceCustomizationByModelCustomizationNameTestException(){
- VnfResourceCustomization vnf = cd.getVnfResourceCustomizationByModelCustomizationName("test", "test234");
+ VnfResourceCustomization vnf = cd.getVnfResourceCustomizationByModelCustomizationName("test", "test234");
}
-
+
@Test(expected = Exception.class)
public void getVnfResourceByModelInvariantIdTestException(){
- VnfResource vnf = cd.getVnfResourceByModelInvariantId("test", "test234");
+ VnfResource vnf = cd.getVnfResourceByModelInvariantId("test", "test234");
}
-
+
@Test(expected = Exception.class)
public void getVnfResourceByIdTestException(){
- VnfResource vnf = cd.getVnfResourceById(19299);
+ VnfResource vnf = cd.getVnfResourceById(19299);
}
-
+
@Test(expected = Exception.class)
public void getVfModuleModelNameTestException(){
- VfModule vnf = cd.getVfModuleModelName("tetes");
+ VfModule vnf = cd.getVfModuleModelName("tetes");
}
-
+
@Test(expected = Exception.class)
public void getVfModuleModelName2TestException(){
- VfModule vnf = cd.getVfModuleModelName("tetes","4kidsl");
+ VfModule vnf = cd.getVfModuleModelName("tetes","4kidsl");
}
-
+
@Test(expected = Exception.class)
public void ggetVfModuleCustomizationByModelNameTestException(){
- VfModuleCustomization vnf = cd.getVfModuleCustomizationByModelName("tetes");
+ VfModuleCustomization vnf = cd.getVfModuleCustomizationByModelName("tetes");
}
-
+
@Test(expected = Exception.class)
public void getNetworkResourceTestException(){
- NetworkResource vnf = cd.getNetworkResource("tetes");
+ NetworkResource vnf = cd.getNetworkResource("tetes");
}
-
+
@Test(expected = Exception.class)
public void getVnfRecipeTestException(){
- VnfRecipe vnf = cd.getVnfRecipe("tetes","ergfedrf","4993493");
+ VnfRecipe vnf = cd.getVnfRecipe("tetes","ergfedrf","4993493");
}
-
+
@Test(expected = Exception.class)
public void getVnfRecipe2TestException(){
- VnfRecipe vnf = cd.getVnfRecipe("tetes","4993493");
+ VnfRecipe vnf = cd.getVnfRecipe("tetes","4993493");
}
-
+
@Test(expected = Exception.class)
public void getVnfRecipeByVfModuleIdTestException(){
- VnfRecipe vnf = cd.getVnfRecipeByVfModuleId("tetes","4993493","vnf");
+ VnfRecipe vnf = cd.getVnfRecipeByVfModuleId("tetes","4993493","vnf");
}
-
+
@Test(expected = Exception.class)
public void getVfModuleTypeTestException(){
- VfModule vnf = cd.getVfModuleType("4993493");
+ VfModule vnf = cd.getVfModuleType("4993493");
}
-
+
@Test(expected = Exception.class)
public void getVfModuleType2TestException(){
- VfModule vnf = cd.getVfModuleType("4993493","vnf");
+ VfModule vnf = cd.getVfModuleType("4993493","vnf");
}
@Test(expected = Exception.class)
public void getVnfResourceByServiceUuidTestException(){
- VnfResource vnf = cd.getVnfResourceByServiceUuid("4993493");
+ VnfResource vnf = cd.getVnfResourceByServiceUuid("4993493");
}
@Test(expected = Exception.class)
public void getVnfResourceByVnfUuidTestException(){
- VnfResource vnf = cd.getVnfResourceByVnfUuid("4993493");
+ VnfResource vnf = cd.getVnfResourceByVnfUuid("4993493");
}
@Test(expected = Exception.class)
public void getVfModuleByModelInvariantUuidTestException(){
- VfModule vnf = cd.getVfModuleByModelInvariantUuid("4993493");
+ VfModule vnf = cd.getVfModuleByModelInvariantUuid("4993493");
}
@Test(expected = Exception.class)
public void getVfModuleByModelCustomizationUuidTestException(){
- VfModuleCustomization vnf = cd.getVfModuleByModelCustomizationUuid("4993493");
+ VfModuleCustomization vnf = cd.getVfModuleByModelCustomizationUuid("4993493");
}
@Test(expected = Exception.class)
public void getVfModuleByModelInvariantUuidAndModelVersionTestException(){
- VfModule vnf = cd.getVfModuleByModelInvariantUuidAndModelVersion("4993493","vnf");
+ VfModule vnf = cd.getVfModuleByModelInvariantUuidAndModelVersion("4993493","vnf");
}
@Test(expected = Exception.class)
public void getVfModuleCustomizationByModelCustomizationIdTestException(){
- VfModuleCustomization vnf = cd.getVfModuleCustomizationByModelCustomizationId("4993493");
+ VfModuleCustomization vnf = cd.getVfModuleCustomizationByModelCustomizationId("4993493");
}
@Test(expected = Exception.class)
public void getVfModuleByModelUuidTestException(){
- VfModule vnf = cd.getVfModuleByModelUuid("4993493");
+ VfModule vnf = cd.getVfModuleByModelUuid("4993493");
}
@Test(expected = Exception.class)
public void getVnfResourceCustomizationByModelCustomizationUuidTestException(){
- VnfResourceCustomization vnf = cd.getVnfResourceCustomizationByModelCustomizationUuid("4993493");
+ VnfResourceCustomization vnf = cd.getVnfResourceCustomizationByModelCustomizationUuid("4993493");
}
@Test(expected = Exception.class)
public void getVnfResourceCustomizationByModelVersionIdTestException(){
- VnfResourceCustomization vnf = cd.getVnfResourceCustomizationByModelVersionId("4993493");
+ VnfResourceCustomization vnf = cd.getVnfResourceCustomizationByModelVersionId("4993493");
}
@Test(expected = Exception.class)
public void getVfModuleByModelCustomizationIdAndVersionTestException(){
- cd.getVfModuleByModelCustomizationIdAndVersion("4993493","test");
+ cd.getVfModuleByModelCustomizationIdAndVersion("4993493","test");
}
@Test(expected = Exception.class)
public void getVfModuleByModelCustomizationIdModelVersionAndModelInvariantIdTestException(){
- cd.getVfModuleByModelCustomizationIdModelVersionAndModelInvariantId("4993493","vnf","test");
+ cd.getVfModuleByModelCustomizationIdModelVersionAndModelInvariantId("4993493","vnf","test");
}
@Test(expected = Exception.class)
public void getVnfResourceCustomizationByModelInvariantIdTest(){
- cd.getVnfResourceCustomizationByModelInvariantId("4993493","vnf","test");
+ cd.getVnfResourceCustomizationByModelInvariantId("4993493","vnf","test");
}
@Test(expected = Exception.class)
public void getVfModuleCustomizationByVnfModuleCustomizationUuidTest(){
- cd.getVfModuleCustomizationByVnfModuleCustomizationUuid("4993493");
+ cd.getVfModuleCustomizationByVnfModuleCustomizationUuid("4993493");
}
@Test(expected = Exception.class)
public void getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionIdTest(){
- cd.getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionId("4993493","test");
+ cd.getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionId("4993493","test");
}
@Test(expected = Exception.class)
public void getAllVfModuleCustomizationstest(){
- cd.getAllVfModuleCustomizations("4993493");
+ cd.getAllVfModuleCustomizations("4993493");
}
@Test(expected = Exception.class)
public void getVnfResourceByModelUuidTest(){
- cd.getVnfResourceByModelUuid("4993493");
+ cd.getVnfResourceByModelUuid("4993493");
}
@Test(expected = Exception.class)
public void getVnfResCustomToVfModuleTest(){
- cd.getVnfResCustomToVfModule("4993493","test");
+ cd.getVnfResCustomToVfModule("4993493","test");
}
@Test(expected = Exception.class)
public void getVfModulesForVnfResourceTest(){
- VnfResource vnfResource = new VnfResource();
- vnfResource.setModelUuid("48839");
- cd.getVfModulesForVnfResource(vnfResource);
+ VnfResource vnfResource = new VnfResource();
+ vnfResource.setModelUuid("48839");
+ cd.getVfModulesForVnfResource(vnfResource);
}
@Test(expected = Exception.class)
public void getVfModulesForVnfResource2Test(){
- cd.getVfModulesForVnfResource("4993493");
+ cd.getVfModulesForVnfResource("4993493");
}
@Test(expected = Exception.class)
public void getServiceByUuidTest(){
- cd.getServiceByUuid("4993493");
+ cd.getServiceByUuid("4993493");
}
@Test(expected = Exception.class)
public void getNetworkResourceById2Test(){
- cd.getNetworkResourceById(4993493);
+ cd.getNetworkResourceById(4993493);
}
@Test(expected = Exception.class)
public void getNetworkResourceByIdTest(){
@@ -327,431 +472,431 @@ public class CatalogDatabaseTest {
}
@Test
public void isEmptyOrNullTest(){
- boolean is = cd.isEmptyOrNull("4993493");
- assertFalse(is);
+ boolean is = cd.isEmptyOrNull("4993493");
+ assertFalse(is);
}
@Test(expected = Exception.class)
public void getSTRTest(){
- cd.getSTR("4993493","test","vnf");
+ cd.getSTR("4993493","test","vnf");
}
@Test(expected = Exception.class)
public void getVRCtoVFMCTest(){
- cd.getVRCtoVFMC("4993493","388492");
+ cd.getVRCtoVFMC("4993493","388492");
}
@Test(expected = Exception.class)
public void getVfModuleTypeByUuidTestException(){
- cd.getVfModuleTypeByUuid("4993493");
+ cd.getVfModuleTypeByUuid("4993493");
}
-
+
@Test(expected = Exception.class)
public void getTempNetworkHeatTemplateLookupTest(){
- cd.getTempNetworkHeatTemplateLookup("4993493");
+ cd.getTempNetworkHeatTemplateLookup("4993493");
}
-
+
@Test(expected = Exception.class)
public void getAllNetworksByServiceModelUuidTest(){
- cd.getAllNetworksByServiceModelUuid("4993493");
+ cd.getAllNetworksByServiceModelUuid("4993493");
}
@Test(expected = Exception.class)
public void getAllNetworksByServiceModelInvariantUuidTest(){
- cd.getAllNetworksByServiceModelInvariantUuid("4993493");
+ cd.getAllNetworksByServiceModelInvariantUuid("4993493");
}
@Test(expected = Exception.class)
public void getAllNetworksByServiceModelInvariantUuid2Test(){
- cd.getAllNetworksByServiceModelInvariantUuid("4993493","test");
+ cd.getAllNetworksByServiceModelInvariantUuid("4993493","test");
}
@Test(expected = Exception.class)
public void getAllNetworksByNetworkModelCustomizationUuidTest(){
- cd.getAllNetworksByNetworkModelCustomizationUuid("4993493");
+ cd.getAllNetworksByNetworkModelCustomizationUuid("4993493");
}
@Test(expected = Exception.class)
public void getAllNetworksByNetworkTypeTest(){
- cd.getAllNetworksByNetworkType("4993493");
+ cd.getAllNetworksByNetworkType("4993493");
}
@Test(expected = Exception.class)
public void getAllVfmcForVrcTest(){
- VnfResourceCustomization re = new VnfResourceCustomization();
- re.setModelCustomizationUuid("377483");
- cd.getAllVfmcForVrc(re);
+ VnfResourceCustomization re = new VnfResourceCustomization();
+ re.setModelCustomizationUuid("377483");
+ cd.getAllVfmcForVrc(re);
}
@Test(expected = Exception.class)
public void getAllVnfsByServiceModelUuidTest(){
- cd.getAllVnfsByServiceModelUuid("4993493");
+ cd.getAllVnfsByServiceModelUuid("4993493");
}
@Test(expected = Exception.class)
public void getAllVnfsByServiceModelInvariantUuidTest(){
- cd.getAllVnfsByServiceModelInvariantUuid("4993493");
+ cd.getAllVnfsByServiceModelInvariantUuid("4993493");
}
@Test(expected = Exception.class)
public void getAllVnfsByServiceModelInvariantUuid2Test(){
- cd.getAllVnfsByServiceModelInvariantUuid("4993493","test");
+ cd.getAllVnfsByServiceModelInvariantUuid("4993493","test");
}
@Test(expected = Exception.class)
public void getAllVnfsByServiceNameTest(){
- cd.getAllVnfsByServiceName("4993493","test");
+ cd.getAllVnfsByServiceName("4993493","test");
}
@Test(expected = Exception.class)
public void getAllVnfsByServiceName2Test(){
- cd.getAllVnfsByServiceName("4993493");
+ cd.getAllVnfsByServiceName("4993493");
}
@Test(expected = Exception.class)
public void getAllVnfsByVnfModelCustomizationUuidTest(){
- cd.getAllVnfsByVnfModelCustomizationUuid("4993493");
+ cd.getAllVnfsByVnfModelCustomizationUuid("4993493");
}
@Test(expected = Exception.class)
public void getAllAllottedResourcesByServiceModelUuidTest(){
- cd.getAllAllottedResourcesByServiceModelUuid("4993493");
+ cd.getAllAllottedResourcesByServiceModelUuid("4993493");
}
@Test(expected = Exception.class)
public void getAllAllottedResourcesByServiceModelInvariantUuidTest(){
- cd.getAllAllottedResourcesByServiceModelInvariantUuid("4993493");
+ cd.getAllAllottedResourcesByServiceModelInvariantUuid("4993493");
}
@Test(expected = Exception.class)
public void getAllAllottedResourcesByServiceModelInvariantUuid2Test(){
- cd.getAllAllottedResourcesByServiceModelInvariantUuid("4993493","test");
+ cd.getAllAllottedResourcesByServiceModelInvariantUuid("4993493","test");
}
@Test(expected = Exception.class)
public void getAllAllottedResourcesByArModelCustomizationUuidTest(){
- cd.getAllAllottedResourcesByArModelCustomizationUuid("4993493");
+ cd.getAllAllottedResourcesByArModelCustomizationUuid("4993493");
}
@Test(expected = Exception.class)
public void getAllottedResourceByModelUuidTest(){
- cd.getAllottedResourceByModelUuid("4993493");
+ cd.getAllottedResourceByModelUuid("4993493");
}
@Test(expected = Exception.class)
public void getAllResourcesByServiceModelUuidTest(){
- cd.getAllResourcesByServiceModelUuid("4993493");
+ cd.getAllResourcesByServiceModelUuid("4993493");
}
@Test(expected = Exception.class)
public void getAllResourcesByServiceModelInvariantUuidTest(){
- cd.getAllResourcesByServiceModelInvariantUuid("4993493");
+ cd.getAllResourcesByServiceModelInvariantUuid("4993493");
}
-
+
@Test(expected = Exception.class)
public void getAllResourcesByServiceModelInvariantUuid2Test(){
- cd.getAllResourcesByServiceModelInvariantUuid("4993493","test");
+ cd.getAllResourcesByServiceModelInvariantUuid("4993493","test");
}
@Test(expected = Exception.class)
public void getSingleNetworkByModelCustomizationUuidTest(){
- cd.getSingleNetworkByModelCustomizationUuid("4993493");
+ cd.getSingleNetworkByModelCustomizationUuid("4993493");
}
@Test(expected = Exception.class)
public void getSingleAllottedResourceByModelCustomizationUuidTest(){
- cd.getSingleAllottedResourceByModelCustomizationUuid("4993493");
+ cd.getSingleAllottedResourceByModelCustomizationUuid("4993493");
}
@Test(expected = Exception.class)
public void getVfModuleRecipeTest(){
- cd.getVfModuleRecipe("4993493","test","get");
+ cd.getVfModuleRecipe("4993493","test","get");
}
@Test(expected = Exception.class)
public void getVfModuleTest(){
- cd.getVfModule("4993493","test","get","v2","vnf");
+ cd.getVfModule("4993493","test","get","v2","vnf");
}
@Test(expected = Exception.class)
public void getVnfComponentsRecipeTest(){
- cd.getVnfComponentsRecipe("4993493","test","v2","vnf","get","3992");
+ cd.getVnfComponentsRecipe("4993493","test","v2","vnf","get","3992");
}
@Test(expected = Exception.class)
public void getVnfComponentsRecipeByVfModuleTest(){
- List <VfModule> resultList = new ArrayList<>();
- VfModule m = new VfModule();
- resultList.add(m);
- cd.getVnfComponentsRecipeByVfModule(resultList,"4993493");
+ List <VfModule> resultList = new ArrayList<>();
+ VfModule m = new VfModule();
+ resultList.add(m);
+ cd.getVnfComponentsRecipeByVfModule(resultList,"4993493");
}
@Test(expected = Exception.class)
public void getAllVnfResourcesTest(){
- cd.getAllVnfResources();
+ cd.getAllVnfResources();
}
@Test(expected = Exception.class)
public void getVnfResourcesByRoleTest(){
- cd.getVnfResourcesByRole("4993493");
+ cd.getVnfResourcesByRole("4993493");
}
@Test(expected = Exception.class)
public void getVnfResourceCustomizationsByRoleTest(){
- cd.getVnfResourceCustomizationsByRole("4993493");
+ cd.getVnfResourceCustomizationsByRole("4993493");
}
@Test(expected = Exception.class)
public void getAllNetworkResourcesTest(){
- cd.getAllNetworkResources();
+ cd.getAllNetworkResources();
}
@Test(expected = Exception.class)
public void getAllNetworkResourceCustomizationsTest(){
- cd.getAllNetworkResourceCustomizations();
+ cd.getAllNetworkResourceCustomizations();
}
@Test(expected = Exception.class)
public void getAllVfModulesTest(){
- cd.getAllVfModules();
+ cd.getAllVfModules();
}
@Test(expected = Exception.class)
public void getAllVfModuleCustomizationsTest(){
- cd.getAllVfModuleCustomizations();
+ cd.getAllVfModuleCustomizations();
}
@Test(expected = Exception.class)
public void getAllHeatEnvironmentTest(){
- cd.getAllHeatEnvironment();
+ cd.getAllHeatEnvironment();
}
@Test(expected = Exception.class)
public void getHeatEnvironment2Test(){
- cd.getHeatEnvironment(4993493);
+ cd.getHeatEnvironment(4993493);
}
@Test(expected = Exception.class)
public void getNestedTemplatesTest(){
- cd.getNestedTemplates(4993493);
+ cd.getNestedTemplates(4993493);
}
@Test(expected = Exception.class)
public void getNestedTemplates2Test(){
- cd.getNestedTemplates("4993493");
+ cd.getNestedTemplates("4993493");
}
@Test(expected = Exception.class)
public void getHeatFilesTest(){
- cd.getHeatFiles(4993493);
+ cd.getHeatFiles(4993493);
}
@Test(expected = Exception.class)
public void getVfModuleToHeatFilesEntryTest(){
- cd.getVfModuleToHeatFilesEntry("4993493","49959499");
+ cd.getVfModuleToHeatFilesEntry("4993493","49959499");
}
@Test(expected = Exception.class)
public void getServiceToResourceCustomization(){
- cd.getServiceToResourceCustomization("4993493","599349","49900");
+ cd.getServiceToResourceCustomization("4993493","599349","49900");
}
@Test(expected = Exception.class)
public void getHeatFilesForVfModuleTest(){
- cd.getHeatFilesForVfModule("4993493");
+ cd.getHeatFilesForVfModule("4993493");
}
@Test(expected = Exception.class)
public void getHeatTemplateTest(){
- cd.getHeatTemplate("4993493","test","heat");
+ cd.getHeatTemplate("4993493","test","heat");
}
-
+
@Test(expected = Exception.class)
public void saveHeatTemplateTest(){
- HeatTemplate heat = new HeatTemplate();
- Set <HeatTemplateParam> paramSet = new HashSet<HeatTemplateParam>();
- cd.saveHeatTemplate(heat,paramSet);
+ HeatTemplate heat = new HeatTemplate();
+ Set <HeatTemplateParam> paramSet = new HashSet<HeatTemplateParam>();
+ cd.saveHeatTemplate(heat,paramSet);
}
@Test(expected = Exception.class)
public void getHeatEnvironmentTest(){
- cd.getHeatEnvironment("4993493","test","heat");
+ cd.getHeatEnvironment("4993493","test","heat");
}
@Test(expected = Exception.class)
public void getHeatEnvironment3Test(){
- cd.getHeatEnvironment("4993493","test");
+ cd.getHeatEnvironment("4993493","test");
}
@Test(expected = Exception.class)
public void saveHeatEnvironmentTest(){
- HeatEnvironment en = new HeatEnvironment();
- cd.saveHeatEnvironment(en);
+ HeatEnvironment en = new HeatEnvironment();
+ cd.saveHeatEnvironment(en);
}
@Test(expected = Exception.class)
public void saveHeatTemplate2Test(){
- HeatTemplate heat = new HeatTemplate();
- cd.saveHeatTemplate(heat);
+ HeatTemplate heat = new HeatTemplate();
+ cd.saveHeatTemplate(heat);
}
@Test(expected = Exception.class)
public void saveHeatFileTest(){
- HeatFiles hf = new HeatFiles();
- cd.saveHeatFile(hf);
+ HeatFiles hf = new HeatFiles();
+ cd.saveHeatFile(hf);
}
@Test(expected = Exception.class)
public void saveVnfRecipeTest(){
- VnfRecipe vr = new VnfRecipe();
- cd.saveVnfRecipe(vr);
+ VnfRecipe vr = new VnfRecipe();
+ cd.saveVnfRecipe(vr);
}
@Test(expected = Exception.class)
public void saveVnfComponentsRecipe(){
- VnfComponentsRecipe vr = new VnfComponentsRecipe();
- cd.saveVnfComponentsRecipe(vr);
+ VnfComponentsRecipe vr = new VnfComponentsRecipe();
+ cd.saveVnfComponentsRecipe(vr);
}
@Test(expected = Exception.class)
public void saveOrUpdateVnfResourceTest(){
- VnfResource vr = new VnfResource();
- cd.saveOrUpdateVnfResource(vr);
+ VnfResource vr = new VnfResource();
+ cd.saveOrUpdateVnfResource(vr);
}
@Test(expected = Exception.class)
public void saveVnfResourceCustomizationTest(){
- VnfResourceCustomization vr = new VnfResourceCustomization();
- cd.saveVnfResourceCustomization(vr);
+ VnfResourceCustomization vr = new VnfResourceCustomization();
+ cd.saveVnfResourceCustomization(vr);
}
@Test(expected = Exception.class)
public void saveAllottedResourceCustomizationTest(){
- AllottedResourceCustomization arc = new AllottedResourceCustomization();
- cd.saveAllottedResourceCustomization(arc);
+ AllottedResourceCustomization arc = new AllottedResourceCustomization();
+ cd.saveAllottedResourceCustomization(arc);
}
@Test(expected = Exception.class)
public void saveAllottedResourceTest(){
- AllottedResource ar = new AllottedResource();
- cd.saveAllottedResource(ar);
+ AllottedResource ar = new AllottedResource();
+ cd.saveAllottedResource(ar);
}
@Test(expected = Exception.class)
public void saveNetworkResourceTest() throws RecordNotFoundException {
- NetworkResource nr = new NetworkResource();
- cd.saveNetworkResource(nr);
+ NetworkResource nr = new NetworkResource();
+ cd.saveNetworkResource(nr);
}
@Test(expected = Exception.class)
public void saveToscaCsarTest()throws RecordNotFoundException {
- ToscaCsar ts = new ToscaCsar();
- cd.saveToscaCsar(ts);
+ ToscaCsar ts = new ToscaCsar();
+ cd.saveToscaCsar(ts);
}
@Test(expected = Exception.class)
public void getToscaCsar(){
- cd.getToscaCsar("4993493");
+ cd.getToscaCsar("4993493");
}
@Test(expected = Exception.class)
public void saveTempNetworkHeatTemplateLookupTest(){
- TempNetworkHeatTemplateLookup t = new TempNetworkHeatTemplateLookup();
- cd.saveTempNetworkHeatTemplateLookup(t);
+ TempNetworkHeatTemplateLookup t = new TempNetworkHeatTemplateLookup();
+ cd.saveTempNetworkHeatTemplateLookup(t);
}
@Test(expected = Exception.class)
public void saveVfModuleToHeatFiles(){
- VfModuleToHeatFiles v = new VfModuleToHeatFiles();
- cd.saveVfModuleToHeatFiles(v);
+ VfModuleToHeatFiles v = new VfModuleToHeatFiles();
+ cd.saveVfModuleToHeatFiles(v);
}
@Test(expected = Exception.class)
public void saveVnfResourceToVfModuleCustomizationTest() throws RecordNotFoundException {
- VnfResourceCustomization v =new VnfResourceCustomization();
- VfModuleCustomization vm = new VfModuleCustomization();
- cd.saveVnfResourceToVfModuleCustomization(v, vm);
+ VnfResourceCustomization v =new VnfResourceCustomization();
+ VfModuleCustomization vm = new VfModuleCustomization();
+ cd.saveVnfResourceToVfModuleCustomization(v, vm);
}
@Test(expected = Exception.class)
public void saveNetworkResourceCustomizationTest() throws RecordNotFoundException {
- NetworkResourceCustomization nrc = new NetworkResourceCustomization();
- cd.saveNetworkResourceCustomization(nrc);
+ NetworkResourceCustomization nrc = new NetworkResourceCustomization();
+ cd.saveNetworkResourceCustomization(nrc);
}
-
+
@Test(expected = Exception.class)
public void saveServiceToNetworksTest(){
- AllottedResource ar = new AllottedResource();
- cd.saveAllottedResource(ar);
+ AllottedResource ar = new AllottedResource();
+ cd.saveAllottedResource(ar);
}
@Test(expected = Exception.class)
public void saveServiceToResourceCustomizationTest(){
- ServiceToResourceCustomization ar = new ServiceToResourceCustomization();
- cd.saveServiceToResourceCustomization(ar);
+ ServiceToResourceCustomization ar = new ServiceToResourceCustomization();
+ cd.saveServiceToResourceCustomization(ar);
}
@Test(expected = Exception.class)
public void saveServiceTest(){
- Service ar = new Service();
- cd.saveService(ar);
+ Service ar = new Service();
+ cd.saveService(ar);
}
@Test(expected = Exception.class)
public void saveOrUpdateVfModuleTest(){
- VfModule ar = new VfModule();
- cd.saveOrUpdateVfModule(ar);
+ VfModule ar = new VfModule();
+ cd.saveOrUpdateVfModule(ar);
}
@Test(expected = Exception.class)
public void saveOrUpdateVfModuleCustomizationTest(){
- VfModuleCustomization ar = new VfModuleCustomization();
- cd.saveOrUpdateVfModuleCustomization(ar);
+ VfModuleCustomization ar = new VfModuleCustomization();
+ cd.saveOrUpdateVfModuleCustomization(ar);
}
-
+
@Test(expected = Exception.class)
public void getNestedHeatTemplateTest(){
- cd.getNestedHeatTemplate(101,201);
+ cd.getNestedHeatTemplate(101,201);
}
@Test(expected = Exception.class)
public void getNestedHeatTemplate2Test(){
- cd.getNestedHeatTemplate("1002","1002");
+ cd.getNestedHeatTemplate("1002","1002");
}
@Test(expected = Exception.class)
public void saveNestedHeatTemplateTest(){
- HeatTemplate ar = new HeatTemplate();
- cd.saveNestedHeatTemplate("1001",ar,"test");
+ HeatTemplate ar = new HeatTemplate();
+ cd.saveNestedHeatTemplate("1001",ar,"test");
}
@Test(expected = Exception.class)
public void getHeatFiles2Test(){
- VfModuleCustomization ar = new VfModuleCustomization();
- cd.getHeatFiles(101,"test","1001","v2");
+ VfModuleCustomization ar = new VfModuleCustomization();
+ cd.getHeatFiles(101,"test","1001","v2");
}
@Test(expected = Exception.class)
public void getHeatFiles3Test(){
- VfModuleCustomization ar = new VfModuleCustomization();
- cd.getHeatFiles("200192");
+ VfModuleCustomization ar = new VfModuleCustomization();
+ cd.getHeatFiles("200192");
}
@Test(expected = Exception.class)
public void saveHeatFilesTest(){
- HeatFiles ar = new HeatFiles();
- cd.saveHeatFiles(ar);
+ HeatFiles ar = new HeatFiles();
+ cd.saveHeatFiles(ar);
}
@Test(expected = Exception.class)
public void saveVfModuleToHeatFilesTest(){
- HeatFiles ar = new HeatFiles();
- cd.saveVfModuleToHeatFiles("3772893",ar);
+ HeatFiles ar = new HeatFiles();
+ cd.saveVfModuleToHeatFiles("3772893",ar);
}
@Test
public void getNetworkResourceByModelUuidTest(){
-
- cd.getNetworkResourceByModelUuid("3899291");
+
+ cd.getNetworkResourceByModelUuid("3899291");
}
@Test(expected = Exception.class)
public void getNetworkRecipeTest(){
-
- cd.getNetworkRecipe("test","test1","test2");
+
+ cd.getNetworkRecipe("test","test1","test2");
}
@Test(expected = Exception.class)
public void getNetworkRecipe2Test(){
-
- cd.getNetworkRecipe("test","test1");
+
+ cd.getNetworkRecipe("test","test1");
}
@Test
public void getNetworkResourceByModelCustUuidTest(){
-
- cd.getNetworkResourceByModelCustUuid("test");
+
+ cd.getNetworkResourceByModelCustUuid("test");
}
@Test(expected = Exception.class)
public void getVnfComponentsRecipe2Test(){
-
- cd.getVnfComponentsRecipe("test1","test2","test3","test4");
+
+ cd.getVnfComponentsRecipe("test1","test2","test3","test4");
}
@Test(expected = Exception.class)
public void getVnfComponentsRecipeByVfModuleModelUUIdTest(){
-
- cd.getVnfComponentsRecipeByVfModuleModelUUId("test1","test2","test3");
+
+ cd.getVnfComponentsRecipeByVfModuleModelUUId("test1","test2","test3");
}
@Test(expected = Exception.class)
public void getVnfComponentRecipesTest(){
-
- cd.getVnfComponentRecipes("test");
+
+ cd.getVnfComponentRecipes("test");
}
@Test(expected = Exception.class)
public void saveOrUpdateVnfComponentTest(){
- VnfComponent ar = new VnfComponent();
- cd.saveOrUpdateVnfComponent(ar);
+ VnfComponent ar = new VnfComponent();
+ cd.saveOrUpdateVnfComponent(ar);
}
-
+
@Test(expected = Exception.class)
public void getVfModule2Test(){
-
- cd.getVfModule("test");
+
+ cd.getVfModule("test");
}
@Test(expected = Exception.class)
public void getVfModuleByModelUUIDTest(){
-
- cd.getVfModuleByModelUUID("test");
+
+ cd.getVfModuleByModelUUID("test");
}
@Test(expected = Exception.class)
public void getServiceRecipeByModelUUIDTest(){
-
- cd.getServiceRecipeByModelUUID("test1","test2");
+
+ cd.getServiceRecipeByModelUUID("test1","test2");
}
@Test(expected = Exception.class)
public void getModelRecipeTest(){
-
- cd.getModelRecipe("test1","test2","test3");
+
+ cd.getModelRecipe("test1","test2","test3");
}
@Test(expected = Exception.class)
public void healthCheck(){
-
- cd.healthCheck();
+
+ cd.healthCheck();
}
@Test(expected = Exception.class)
public void executeQuerySingleRow(){
- VnfComponent ar = new VnfComponent();
- HashMap<String, String> variables = new HashMap<String, String>();
- cd.executeQuerySingleRow("tets",variables,false);
+ VnfComponent ar = new VnfComponent();
+ HashMap<String, String> variables = new HashMap<String, String>();
+ cd.executeQuerySingleRow("tets",variables,false);
}
@Test(expected = Exception.class)
public void executeQueryMultipleRows(){
- HashMap<String, String> variables = new HashMap<String, String>();
- cd.executeQueryMultipleRows("select",variables,false);
+ HashMap<String, String> variables = new HashMap<String, String>();
+ cd.executeQueryMultipleRows("select",variables,false);
}
}