summaryrefslogtreecommitdiffstats
path: root/catalog-model/src/test/java/org
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2020-04-06 15:44:56 +0100
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-05-07 08:14:26 +0000
commitf8bc4f94da584d5861827df7ee2107c33f514a55 (patch)
tree4f16ccc40d1ecfce5b6d1e85ce731f9f1eb3d45d /catalog-model/src/test/java/org
parenta36531c38fe1a9234b8dbeaed5505cf3ca48de26 (diff)
Support configuring of tosca type for categories
Signed-off-by: MichaelMorris <michael.morris@est.tech> Issue-ID: SDC-2877 Change-Id: I3160c5089979757628f31a44b01836236563b770
Diffstat (limited to 'catalog-model/src/test/java/org')
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/ResourceTest.java39
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/ServiceTest.java543
2 files changed, 314 insertions, 268 deletions
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ResourceTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ResourceTest.java
index bb72c53033..cb50c9601c 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ResourceTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ResourceTest.java
@@ -20,11 +20,15 @@
package org.openecomp.sdc.be.model;
+import static org.junit.Assert.assertEquals;
+
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
+import org.openecomp.sdc.be.config.Configuration;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.unittests.utils.ModelConfDependentTest;
@@ -302,13 +306,38 @@ public class ResourceTest extends ModelConfDependentTest {
}
@Test
- public void testFetchGenericTypeToscaNameFromConfig() throws Exception {
- Resource testSubject;
- String result;
+ public void testFetchGenericTypeToscaNameFromConfigNoToscaTypesDefinedForCategories() throws Exception {
+ Resource testSubject = createTestSubject();
+ testSubject.addCategory("CategoryA", "SubCategoryB");
+
+ Configuration existingConfiguration = configurationManager.getConfiguration();
+ Configuration newConfiguration = new Configuration();
+ newConfiguration.setServiceNodeTypes(null);
+ Map<String, String> genericAssetNodeTypes = new HashMap<>();
+ genericAssetNodeTypes.put("VFC", "org.openecomp.resource.abstract.nodes.VFC");
+ newConfiguration.setGenericAssetNodeTypes(genericAssetNodeTypes);
+ configurationManager.setConfiguration(newConfiguration);
+
+ String result = testSubject.fetchGenericTypeToscaNameFromConfig();
+ assertEquals("org.openecomp.resource.abstract.nodes.VFC", result);
+ configurationManager.setConfiguration(existingConfiguration);
+ }
+ @Test
+ public void testFetchGenericTypeToscaNameFromConfigNoToscaTypeDefinedForRelevantCategory() throws Exception {
// default test
- testSubject = createTestSubject();
- result = testSubject.fetchGenericTypeToscaNameFromConfig();
+ Resource testSubject = createTestSubject();
+ testSubject.addCategory("CategoryA", "SubCategoryC");
+ String result = testSubject.fetchGenericTypeToscaNameFromConfig();
+ assertEquals("org.openecomp.resource.abstract.nodes.VFC", result);
+ }
+
+ @Test
+ public void testFetchGenericTypeToscaNameFromConfigToscaTypeDefinedForCategory() throws Exception {
+ Resource testSubject = createTestSubject();
+ testSubject.addCategory("CategoryA", "SubCategoryB");
+ String result = testSubject.fetchGenericTypeToscaNameFromConfig();
+ assertEquals("org.openecomp.resource.abstract.nodes.B", result);
}
@Test
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ServiceTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ServiceTest.java
index b677548773..d84d97b547 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ServiceTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ServiceTest.java
@@ -25,275 +25,292 @@ import org.junit.Test;
import org.openecomp.sdc.be.config.Configuration;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition;
+import org.openecomp.sdc.be.model.category.CategoryDefinition;
import org.openecomp.sdc.common.api.ConfigurationSource;
import org.openecomp.sdc.common.impl.ExternalConfiguration;
import org.openecomp.sdc.common.impl.FSConfigurationSource;
+import static org.junit.Assert.assertEquals;
+
+import java.util.HashMap;
import java.util.Map;
public class ServiceTest {
- protected static ConfigurationManager configurationManager;
- static Configuration.EnvironmentContext environmentContext = new Configuration.EnvironmentContext();
-
- @BeforeClass
- public static void init() {
- String appConfigDir = "src/test/resources/config";
- ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
- appConfigDir);
- configurationManager = new ConfigurationManager(configurationSource);
-
- Configuration configuration = new Configuration();
-
- configuration.setJanusGraphInMemoryGraph(true);
- environmentContext.setDefaultValue("General_Revenue-Bearing");
- configuration.setEnvironmentContext(environmentContext);
-
- configurationManager.setConfiguration(configuration);
- }
-
- private Service createTestSubject() {
- return new Service();
- }
-
- @Test
- public void testCtor() throws Exception {
- new Service(new ComponentMetadataDefinition());
- }
-
- @Test
- public void testGetServiceApiArtifacts() throws Exception {
- Service testSubject;
- Map<String, ArtifactDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getServiceApiArtifacts();
- }
-
-
- @Test
- public void testSetServiceApiArtifacts() throws Exception {
- Service testSubject;
- Map<String, ArtifactDefinition> serviceApiArtifacts = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setServiceApiArtifacts(serviceApiArtifacts);
- }
-
-
- @Test
- public void testGetProjectCode() throws Exception {
- Service testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getProjectCode();
- }
-
-
- @Test
- public void testGetForwardingPaths() throws Exception {
- Service testSubject;
- Map<String, ForwardingPathDataDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getForwardingPaths();
- }
-
-
- @Test
- public void testSetForwardingPaths() throws Exception {
- Service testSubject;
- Map<String, ForwardingPathDataDefinition> forwardingPaths = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setForwardingPaths(forwardingPaths);
- }
-
-
- @Test
- public void testAddForwardingPath() throws Exception {
- Service testSubject;
- ForwardingPathDataDefinition forwardingPathDataDefinition = new ForwardingPathDataDefinition();
- ForwardingPathDataDefinition result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.addForwardingPath(forwardingPathDataDefinition);
- }
-
-
- @Test
- public void testSetProjectCode() throws Exception {
- Service testSubject;
- String projectName = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setProjectCode(projectName);
- }
-
-
- @Test
- public void testGetDistributionStatus() throws Exception {
- Service testSubject;
- DistributionStatusEnum result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getDistributionStatus();
- }
-
-
- @Test
- public void testSetDistributionStatus() throws Exception {
- Service testSubject;
- DistributionStatusEnum distributionStatus = null;
-
- // test 1
- testSubject = createTestSubject();
- distributionStatus = null;
- testSubject.setDistributionStatus(distributionStatus);
- testSubject.setDistributionStatus(DistributionStatusEnum.DISTRIBUTED);
- }
-
-
- @Test
- public void testSetEcompGeneratedNaming() throws Exception {
- Service testSubject;
- Boolean ecompGeneratedNaming = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setEcompGeneratedNaming(ecompGeneratedNaming);
- }
-
-
- @Test
- public void testIsEcompGeneratedNaming() throws Exception {
- Service testSubject;
- Boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.isEcompGeneratedNaming();
- }
-
-
- @Test
- public void testSetNamingPolicy() throws Exception {
- Service testSubject;
- String namingPolicy = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setNamingPolicy(namingPolicy);
- }
-
-
- @Test
- public void testGetNamingPolicy() throws Exception {
- Service testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getNamingPolicy();
- }
-
-
- @Test
- public void testGetEnvironmentContext() throws Exception {
- Service testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getEnvironmentContext();
- }
-
-
- @Test
- public void testSetEnvironmentContext() throws Exception {
- Service testSubject;
- String environmentContext = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setEnvironmentContext(environmentContext);
- }
-
-
- @Test
- public void testSetServiceType() throws Exception {
- Service testSubject;
- String serviceType = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setServiceType(serviceType);
- }
-
-
- @Test
- public void testGetServiceType() throws Exception {
- Service testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getServiceType();
- }
-
-
- @Test
- public void testSetServiceRole() throws Exception {
- Service testSubject;
- String serviceRole = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setServiceRole(serviceRole);
- }
-
-
- @Test
- public void testGetServiceRole() throws Exception {
- Service testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getServiceRole();
- }
-
-
-
-
-
- @Test
- public void testToString() throws Exception {
- Service testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.toString();
- }
-
-
- @Test
- public void testSetSpecificComponetTypeArtifacts() throws Exception {
- Service testSubject;
- Map<String, ArtifactDefinition> specificComponentTypeArtifacts = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setSpecificComponetTypeArtifacts(specificComponentTypeArtifacts);
- }
+ protected static ConfigurationManager configurationManager;
+ static Configuration.EnvironmentContext environmentContext = new Configuration.EnvironmentContext();
+
+ @BeforeClass
+ public static void init() {
+ String appConfigDir = "src/test/resources/config";
+ ConfigurationSource configurationSource =
+ new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
+ configurationManager = new ConfigurationManager(configurationSource);
+ }
+
+ private Service createTestSubject() {
+ return new Service();
+ }
+
+ @Test
+ public void testCtor() throws Exception {
+ new Service(new ComponentMetadataDefinition());
+ }
+
+ @Test
+ public void testGetServiceApiArtifacts() throws Exception {
+ Service testSubject;
+ Map<String, ArtifactDefinition> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getServiceApiArtifacts();
+ }
+
+ @Test
+ public void testSetServiceApiArtifacts() throws Exception {
+ Service testSubject;
+ Map<String, ArtifactDefinition> serviceApiArtifacts = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setServiceApiArtifacts(serviceApiArtifacts);
+ }
+
+ @Test
+ public void testGetProjectCode() throws Exception {
+ Service testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getProjectCode();
+ }
+
+ @Test
+ public void testGetForwardingPaths() throws Exception {
+ Service testSubject;
+ Map<String, ForwardingPathDataDefinition> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getForwardingPaths();
+ }
+
+ @Test
+ public void testSetForwardingPaths() throws Exception {
+ Service testSubject;
+ Map<String, ForwardingPathDataDefinition> forwardingPaths = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setForwardingPaths(forwardingPaths);
+ }
+
+ @Test
+ public void testAddForwardingPath() throws Exception {
+ Service testSubject;
+ ForwardingPathDataDefinition forwardingPathDataDefinition = new ForwardingPathDataDefinition();
+ ForwardingPathDataDefinition result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.addForwardingPath(forwardingPathDataDefinition);
+ }
+
+ @Test
+ public void testSetProjectCode() throws Exception {
+ Service testSubject;
+ String projectName = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setProjectCode(projectName);
+ }
+
+ @Test
+ public void testGetDistributionStatus() throws Exception {
+ Service testSubject;
+ DistributionStatusEnum result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getDistributionStatus();
+ }
+
+ @Test
+ public void testSetDistributionStatus() throws Exception {
+ Service testSubject;
+ DistributionStatusEnum distributionStatus = null;
+
+ // test 1
+ testSubject = createTestSubject();
+ distributionStatus = null;
+ testSubject.setDistributionStatus(distributionStatus);
+ testSubject.setDistributionStatus(DistributionStatusEnum.DISTRIBUTED);
+ }
+
+ @Test
+ public void testSetEcompGeneratedNaming() throws Exception {
+ Service testSubject;
+ Boolean ecompGeneratedNaming = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setEcompGeneratedNaming(ecompGeneratedNaming);
+ }
+
+ @Test
+ public void testIsEcompGeneratedNaming() throws Exception {
+ Service testSubject;
+ Boolean result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.isEcompGeneratedNaming();
+ }
+
+ @Test
+ public void testSetNamingPolicy() throws Exception {
+ Service testSubject;
+ String namingPolicy = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setNamingPolicy(namingPolicy);
+ }
+
+ @Test
+ public void testGetNamingPolicy() throws Exception {
+ Service testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getNamingPolicy();
+ }
+
+ @Test
+ public void testGetEnvironmentContext() throws Exception {
+ Service testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getEnvironmentContext();
+ }
+
+ @Test
+ public void testSetEnvironmentContext() throws Exception {
+ Service testSubject;
+ String environmentContext = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setEnvironmentContext(environmentContext);
+ }
+
+ @Test
+ public void testSetServiceType() throws Exception {
+ Service testSubject;
+ String serviceType = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setServiceType(serviceType);
+ }
+
+ @Test
+ public void testGetServiceType() throws Exception {
+ Service testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getServiceType();
+ }
+
+ @Test
+ public void testSetServiceRole() throws Exception {
+ Service testSubject;
+ String serviceRole = "";
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setServiceRole(serviceRole);
+ }
+
+ @Test
+ public void testGetServiceRole() throws Exception {
+ Service testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getServiceRole();
+ }
+
+ @Test
+ public void testToString() throws Exception {
+ Service testSubject;
+ String result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.toString();
+ }
+
+ @Test
+ public void testSetSpecificComponetTypeArtifacts() throws Exception {
+ Service testSubject;
+ Map<String, ArtifactDefinition> specificComponentTypeArtifacts = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setSpecificComponetTypeArtifacts(specificComponentTypeArtifacts);
+ }
+
+ @Test
+ public void testFetchGenericTypeToscaNameFromConfigNoToscaTypesForCategories() throws Exception {
+ Configuration existingConfiguration = configurationManager.getConfiguration();
+ Configuration newConfiguration = new Configuration();
+ newConfiguration.setServiceNodeTypes(null);
+ Map<String, String> genericAssetNodeTypes = new HashMap<>();
+ genericAssetNodeTypes.put("Service", "org.openecomp.resource.abstract.nodes.service");
+ newConfiguration.setGenericAssetNodeTypes(genericAssetNodeTypes);
+ configurationManager.setConfiguration(newConfiguration);
+
+ Service testSubject = createTestSubject();
+ CategoryDefinition category = new CategoryDefinition();
+ category.setName("CategoryB");
+ testSubject.addCategory(category);
+ String result = testSubject.fetchGenericTypeToscaNameFromConfig();
+ assertEquals("org.openecomp.resource.abstract.nodes.service", result);
+ configurationManager.setConfiguration(existingConfiguration);
+ }
+
+ @Test
+ public void testFetchGenericTypeToscaNameFromConfigNoToscaTypeForRelevantCategory() throws Exception {
+ Service testSubject = createTestSubject();
+ CategoryDefinition category = new CategoryDefinition();
+ category.setName("CategoryD");
+ testSubject.addCategory(category);
+ String result = testSubject.fetchGenericTypeToscaNameFromConfig();
+ assertEquals("org.openecomp.resource.abstract.nodes.service", result);
+ }
+
+ @Test
+ public void testFetchGenericTypeToscaNameFromConfigToscaTypeDefinedForCategory() throws Exception {
+ Service testSubject = createTestSubject();
+ CategoryDefinition category = new CategoryDefinition();
+ category.setName("CategoryB");
+ testSubject.addCategory(category);
+ String result = testSubject.fetchGenericTypeToscaNameFromConfig();
+ assertEquals("org.openecomp.resource.abstract.nodes.B", result);
+
+ Configuration configuration = new Configuration();
+
+ configuration.setServiceNodeTypes(null);
+ configurationManager.setConfiguration(configuration);
+ }
}