aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authormark.j.leonard <mark.j.leonard@gmail.com>2019-03-05 12:28:24 +0000
committermark.j.leonard <mark.j.leonard@gmail.com>2019-03-05 12:28:24 +0000
commitf5dae47e293ae63a7a2f18230b772a699a52566f (patch)
treeaa8b90e1ed811ea3168ad8778baf145857993652 /src/test
parentbe30876e3a3872a7274c944995544836ff31913c (diff)
Move Widget attribute data to the mappings JSON
Extend the TOSCA mappings JSON content by adding a set of of Widget types defining the type name and data-delete flag. In this change the set of supported types (defined by an enum) remains. However the intention is to replace this in a future commit. The hierarchy of annotated Widget types is replaced by this new configuration, which is accessed from the Widget class. Refactoring has been kept to a minimum to simplify the code review process but further improvements can now be made. Ideally the set of supported Widgets can be extended through configuration changes only. Change-Id: I005cfe6976778b14f14c3ad06d8acf3745c8dd8f Issue-ID: AAI-2212 Signed-off-by: mark.j.leonard <mark.j.leonard@gmail.com>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/aai/babel/parser/TestArtifactGeneratorToscaParser.java51
-rw-r--r--src/test/java/org/onap/aai/babel/parser/TestToscaParser.java2
-rw-r--r--src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.java2
-rw-r--r--src/test/java/org/onap/aai/babel/util/ArtifactTestUtils.java11
-rw-r--r--src/test/java/org/onap/aai/babel/util/Resources.java2
-rw-r--r--src/test/java/org/onap/aai/babel/xml/generator/model/TestModel.java4
-rw-r--r--src/test/java/org/onap/aai/babel/xml/generator/model/TestVfModule.java48
-rw-r--r--src/test/java/org/onap/aai/babel/xml/generator/model/TestWidget.java119
-rw-r--r--src/test/resources/empty-tosca-mappings.json0
-rw-r--r--src/test/resources/invalid-tosca-mappings.json1
-rw-r--r--src/test/resources/tosca-mappings.json92
11 files changed, 283 insertions, 49 deletions
diff --git a/src/test/java/org/onap/aai/babel/parser/TestArtifactGeneratorToscaParser.java b/src/test/java/org/onap/aai/babel/parser/TestArtifactGeneratorToscaParser.java
index a538373..4451a28 100644
--- a/src/test/java/org/onap/aai/babel/parser/TestArtifactGeneratorToscaParser.java
+++ b/src/test/java/org/onap/aai/babel/parser/TestArtifactGeneratorToscaParser.java
@@ -25,12 +25,16 @@ import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import org.junit.Test;
import org.mockito.Mockito;
+import org.onap.aai.babel.util.ArtifactTestUtils;
+import org.onap.aai.babel.util.Resources;
+import org.onap.aai.babel.xml.generator.XmlArtifactGenerationException;
import org.onap.aai.babel.xml.generator.data.WidgetConfigurationUtil;
import org.onap.aai.babel.xml.generator.data.WidgetMapping;
import org.onap.aai.babel.xml.generator.model.Resource;
@@ -50,6 +54,49 @@ public class TestArtifactGeneratorToscaParser {
private static final String TEST_UUID = "1234";
/**
+ * Initialize the Generator with an invalid artifact generator properties file path.
+ *
+ * @throws IOException
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void testMissingPropertiesFile() throws IOException {
+ System.setProperty(ArtifactGeneratorToscaParser.PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE, "non-existent.file");
+ ArtifactGeneratorToscaParser.initWidgetConfiguration();
+ }
+
+ /**
+ * Initialize the Generator with an invalid mappings file path.
+ *
+ * @throws IOException
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void testMissingMappingsFile() throws IOException {
+ ArtifactGeneratorToscaParser.initToscaMappingsConfiguration("non-existent.file");
+ }
+
+ /**
+ * Initialize the Generator with no Widget Mappings content.
+ *
+ * @throws IOException
+ */
+ @Test(expected = IOException.class)
+ public void testMissingMappingsContent() throws IOException {
+ String invalidJson = new ArtifactTestUtils().getResourcePath(Resources.EMPTY_TOSCA_MAPPING_CONFIG);
+ ArtifactGeneratorToscaParser.initToscaMappingsConfiguration(invalidJson);
+ }
+
+ /**
+ * Initialize the Generator with invalid Widget Mappings content.
+ *
+ * @throws IOException
+ */
+ @Test(expected = IOException.class)
+ public void testInvalidMappingsContent() throws IOException {
+ String invalidJson = new ArtifactTestUtils().getResourcePath(Resources.INVALID_TOSCA_MAPPING_CONFIG);
+ ArtifactGeneratorToscaParser.initToscaMappingsConfiguration(invalidJson);
+ }
+
+ /**
* Process an Allotted Resource that does not have a Providing Service.
*/
@Test(expected = IllegalArgumentException.class)
@@ -92,9 +139,11 @@ public class TestArtifactGeneratorToscaParser {
/**
* Process a dummy Group object for a Service Resource.
+ *
+ * @throws XmlArtifactGenerationException
*/
@Test
- public void testInstanceGroups() {
+ public void testInstanceGroups() throws XmlArtifactGenerationException {
final String instanceGroupType = "org.openecomp.groups.ResourceInstanceGroup";
WidgetConfigurationUtil.setSupportedInstanceGroups(Collections.singletonList(instanceGroupType));
diff --git a/src/test/java/org/onap/aai/babel/parser/TestToscaParser.java b/src/test/java/org/onap/aai/babel/parser/TestToscaParser.java
index 348e1a1..f94328b 100644
--- a/src/test/java/org/onap/aai/babel/parser/TestToscaParser.java
+++ b/src/test/java/org/onap/aai/babel/parser/TestToscaParser.java
@@ -65,7 +65,7 @@ public class TestToscaParser {
GenerationData data =
generator.generateArtifact(CsarTest.VNF_VENDOR_CSAR.getContent(), ymlFiles, additionalParams);
- assertThat("Number of errors produced", data.getErrorData().size(), is(equalTo(0)));
+ assertThat("Number of errors produced " + data.getErrorData(), data.getErrorData().size(), is(equalTo(0)));
assertThat("Number of resources generated", data.getResultData().size(), is(equalTo(2)));
}
diff --git a/src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.java b/src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.java
index 4921490..fe30be4 100644
--- a/src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.java
+++ b/src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.java
@@ -116,7 +116,7 @@ public class CsarToXmlConverterTest {
*/
@Test
public void testArtifactGeneratorConfigMissing() throws CsarConverterException, IOException {
- exception.expect(CsarConverterException.class);
+ exception.expect(IllegalArgumentException.class);
exception.expectMessage("Cannot generate artifacts. System property artifactgenerator.config not configured");
// Unset the required system property
diff --git a/src/test/java/org/onap/aai/babel/util/ArtifactTestUtils.java b/src/test/java/org/onap/aai/babel/util/ArtifactTestUtils.java
index 01f62cf..f5a5a94 100644
--- a/src/test/java/org/onap/aai/babel/util/ArtifactTestUtils.java
+++ b/src/test/java/org/onap/aai/babel/util/ArtifactTestUtils.java
@@ -78,6 +78,17 @@ public class ArtifactTestUtils {
}
/**
+ * Load the Widget to UUID mappings from the Artifact Generator Properties (resource).
+ *
+ * @throws IOException
+ * if the properties file is not loaded
+ */
+ public void loadWidgetMappings() throws IOException {
+ ArtifactGeneratorToscaParser.initToscaMappingsConfiguration(getResourcePath(Resources.TOSCA_MAPPING_CONFIG));
+ }
+
+
+ /**
* Specific test method for the YAML Extractor test.
*
* @param toscaFiles
diff --git a/src/test/java/org/onap/aai/babel/util/Resources.java b/src/test/java/org/onap/aai/babel/util/Resources.java
index bbd663d..a8cffdb 100644
--- a/src/test/java/org/onap/aai/babel/util/Resources.java
+++ b/src/test/java/org/onap/aai/babel/util/Resources.java
@@ -27,5 +27,7 @@ public class Resources {
public static final String ARTIFACT_GENERATOR_CONFIG = "artifact-generator.properties";
public static final String TOSCA_MAPPING_CONFIG = "tosca-mappings.json";
+ public static final String EMPTY_TOSCA_MAPPING_CONFIG = "empty-tosca-mappings.json";
+ public static final String INVALID_TOSCA_MAPPING_CONFIG = "invalid-tosca-mappings.json";
}
diff --git a/src/test/java/org/onap/aai/babel/xml/generator/model/TestModel.java b/src/test/java/org/onap/aai/babel/xml/generator/model/TestModel.java
index 92b548a..4c5ff20 100644
--- a/src/test/java/org/onap/aai/babel/xml/generator/model/TestModel.java
+++ b/src/test/java/org/onap/aai/babel/xml/generator/model/TestModel.java
@@ -46,7 +46,7 @@ public class TestModel {
private Service serviceModel = new Service();
private List<Resource> resourceModels =
Arrays.asList(new Resource(Type.CR, true), new Resource(Type.INSTANCE_GROUP, true));
- private Widget widgetModel = new OamNetwork();
+ private Widget widgetModel = new Widget(Type.OAM_NETWORK, "oam-network", true);
private Model anonymousModel;
static {
@@ -54,7 +54,7 @@ public class TestModel {
}
/**
- * Initialise the Artifact Generator with filtering and mapping configuration. Also Load the Widget to UUID mappings
+ * Initialize the Artifact Generator with filtering and mapping configuration. Also Load the Widget to UUID mappings
* from the Artifact Generator properties.
*
* @throws IOException
diff --git a/src/test/java/org/onap/aai/babel/xml/generator/model/TestVfModule.java b/src/test/java/org/onap/aai/babel/xml/generator/model/TestVfModule.java
index 451d2bb..4171023 100644
--- a/src/test/java/org/onap/aai/babel/xml/generator/model/TestVfModule.java
+++ b/src/test/java/org/onap/aai/babel/xml/generator/model/TestVfModule.java
@@ -33,6 +33,7 @@ import java.util.Map;
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.aai.babel.util.ArtifactTestUtils;
+import org.onap.aai.babel.xml.generator.XmlArtifactGenerationException;
import org.onap.aai.babel.xml.generator.model.Widget.Type;
/**
@@ -44,9 +45,15 @@ public class TestVfModule {
System.setProperty("APP_HOME", ".");
}
+ /**
+ * @throws IOException
+ * if a properties file is not loaded
+ */
@BeforeClass
public static void setup() throws IOException {
- new ArtifactTestUtils().loadWidgetToUuidMappings();
+ ArtifactTestUtils util = new ArtifactTestUtils();
+ util.loadWidgetToUuidMappings();
+ util.loadWidgetMappings();
}
/**
@@ -80,21 +87,22 @@ public class TestVfModule {
}
@Test
- public void testAddVServerWidgetToVf() {
+ public void testAddVServerWidgetToVf() throws XmlArtifactGenerationException {
assertAddWidget(createNewVfModule(), Type.VSERVER);
}
@Test
- public void testAddServiceWidgetToVf() {
+ public void testAddServiceWidgetToVf() throws XmlArtifactGenerationException {
assertAddWidget(createNewVfModule(), Type.SERVICE);
}
/**
* Add a new Widget to a VF Module, where the Widget is NOT set as a member. N.B. For the current VF Module
* implementation the actual Widget type is not important.
+ * @throws XmlArtifactGenerationException
*/
@Test
- public void testNonMemberWidgetToVf() {
+ public void testNonMemberWidgetToVf() throws XmlArtifactGenerationException {
Resource vfModule = createNewVfModule();
assertThat(vfModule.addWidget(createNewWidget(Type.SERVICE)), is(false));
assertNumberOfWidgets(vfModule, 0);
@@ -102,9 +110,10 @@ public class TestVfModule {
/**
* OAM Network is specifically excluded from a VF Module.
+ * @throws XmlArtifactGenerationException
*/
@Test
- public void testAddOamNetworkWidgetToVf() {
+ public void testAddOamNetworkWidgetToVf() throws XmlArtifactGenerationException {
Resource vfModule = createNewVfModule();
assertThat(createNewWidgetForModule(vfModule, Type.OAM_NETWORK), is(false));
assertNumberOfWidgets(vfModule, 0);
@@ -117,9 +126,10 @@ public class TestVfModule {
* <li>Add a Volume Widget</li>
* <li>Add a vserver Widget</li>
* <li>Check that the Volume Widget appears under the vserver</li>
+ * @throws XmlArtifactGenerationException
*/
@Test
- public void testAddVolumeWidgetToVf() {
+ public void testAddVolumeWidgetToVf() throws XmlArtifactGenerationException {
Resource vfModule = createNewVfModule();
// Adding a Volume widget has no effect until a vserver widget is added.
@@ -149,9 +159,10 @@ public class TestVfModule {
* <li>Add an L-Interface Widget</li>
* <li>Add a vserver Widget</li>
* <li>Check that the L-Interface Widget appears under the vserver</li>
+ * @throws XmlArtifactGenerationException
*/
@Test
- public void testAddLinterfaceWidgetToVf() {
+ public void testAddLinterfaceWidgetToVf() throws XmlArtifactGenerationException {
Resource vfModule = createNewVfModule();
// Adding an L-Interface widget has no effect until a vserver widget is added.
@@ -182,9 +193,10 @@ public class TestVfModule {
* <li>Add an L-Interface Widget</li>
* <li>Add a vserver Widget</li>
* <li>Check that both Widgets appear under the vserver</li>
+ * @throws XmlArtifactGenerationException
*/
@Test
- public void testAddVolumeAndLinterfaceWidgetToVf() {
+ public void testAddVolumeAndLinterfaceWidgetToVf() throws XmlArtifactGenerationException {
Resource vfModule = createNewVfModule();
// Adding a Volume widget has no effect until a vserver widget is added.
@@ -222,8 +234,9 @@ public class TestVfModule {
* @param widgetType
* type of Widget to create
* @return a new Widget
+ * @throws XmlArtifactGenerationException
*/
- private Widget createNewWidget(Type widgetType) {
+ private Widget createNewWidget(Type widgetType) throws XmlArtifactGenerationException {
return Widget.getWidget(widgetType);
}
@@ -257,8 +270,9 @@ public class TestVfModule {
* the VF Module to update
* @param widgetType
* the type of Widget to create and add
+ * @throws XmlArtifactGenerationException
*/
- private void assertAddWidget(Resource vfModule, Type widgetType) {
+ private void assertAddWidget(Resource vfModule, Type widgetType) throws XmlArtifactGenerationException {
assertThat(createNewWidgetForModule(vfModule, widgetType), is(true));
}
@@ -269,8 +283,9 @@ public class TestVfModule {
* the VF Module
* @param widgetType
* the type of Widget to create and attempt to add
+ * @throws XmlArtifactGenerationException
*/
- private void assertFailToAddWidget(Resource vfModule, Type widgetType) {
+ private void assertFailToAddWidget(Resource vfModule, Type widgetType) throws XmlArtifactGenerationException {
assertThat(createNewWidgetForModule(vfModule, widgetType), is(false));
}
@@ -282,8 +297,9 @@ public class TestVfModule {
* @param widgetType
* the type of Widget to create and attempt to add
* @return whether or not the Widget was added to the module
+ * @throws XmlArtifactGenerationException
*/
- private boolean createNewWidgetForModule(Resource vfModule, Type widgetType) {
+ private boolean createNewWidgetForModule(Resource vfModule, Type widgetType) throws XmlArtifactGenerationException {
Widget widget = createNewWidget(widgetType);
setWidgetAsMember(vfModule, widget);
return vfModule.addWidget(widget);
@@ -311,9 +327,10 @@ public class TestVfModule {
* @param vfModule
* the VF Module to update
* @return the number of Widgets present in the vserver on creation
+ * @throws XmlArtifactGenerationException
*/
- private int createVserverForVf(Resource vfModule) {
- VServerWidget vserverWidget = (VServerWidget) createNewWidget(Type.VSERVER);
+ private int createVserverForVf(Resource vfModule) throws XmlArtifactGenerationException {
+ Widget vserverWidget = createNewWidget(Type.VSERVER);
assertNumberOfWidgets(vfModule, 0);
final int initialWidgetCount = addVserverToVf(vfModule, vserverWidget);
assertNumberOfWidgets(vfModule, 1);
@@ -328,8 +345,9 @@ public class TestVfModule {
* @param vserverWidget
* the Widget to add
* @return initial widget count for the vserver Widget
+ * @throws XmlArtifactGenerationException
*/
- private int addVserverToVf(Resource vfModule, VServerWidget vserverWidget) {
+ private int addVserverToVf(Resource vfModule, Widget vserverWidget) throws XmlArtifactGenerationException {
// A vserver (initially) has Flavor, Image, Tenant and Vfc.
final int initialWidgetCount = 4;
assertNumberOfWidgets(vserverWidget, initialWidgetCount);
diff --git a/src/test/java/org/onap/aai/babel/xml/generator/model/TestWidget.java b/src/test/java/org/onap/aai/babel/xml/generator/model/TestWidget.java
index d7fe4af..da6e4d5 100644
--- a/src/test/java/org/onap/aai/babel/xml/generator/model/TestWidget.java
+++ b/src/test/java/org/onap/aai/babel/xml/generator/model/TestWidget.java
@@ -21,9 +21,7 @@
package org.onap.aai.babel.xml.generator.model;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
import java.io.IOException;
@@ -31,11 +29,12 @@ import java.util.Collections;
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.aai.babel.util.ArtifactTestUtils;
+import org.onap.aai.babel.xml.generator.XmlArtifactGenerationException;
import org.onap.aai.babel.xml.generator.model.Widget.Type;
import org.onap.aai.babel.xml.generator.types.ModelType;
/**
- * Direct tests of the Widget class for code coverage.
+ * Direct tests of the Widget class for code coverage.
*/
public class TestWidget {
@@ -51,44 +50,106 @@ public class TestWidget {
*/
@BeforeClass
public static void setup() throws IOException {
- new ArtifactTestUtils().loadWidgetToUuidMappings();
+ ArtifactTestUtils util = new ArtifactTestUtils();
+ util.loadWidgetToUuidMappings();
+ util.loadWidgetMappings();
}
@Test
- public void testGetWidgets() {
- assertThat(Widget.getWidget(Type.SERVICE), instanceOf(ServiceWidget.class));
- assertThat(Widget.getWidget(Type.VF), instanceOf(VfWidget.class));
- assertThat(Widget.getWidget(Type.VFC), instanceOf(VfcWidget.class));
- assertThat(Widget.getWidget(Type.VSERVER), instanceOf(VServerWidget.class));
- assertThat(Widget.getWidget(Type.VOLUME), instanceOf(VolumeWidget.class));
- assertThat(Widget.getWidget(Type.FLAVOR), instanceOf(FlavorWidget.class));
- assertThat(Widget.getWidget(Type.TENANT), instanceOf(TenantWidget.class));
- assertThat(Widget.getWidget(Type.VOLUME_GROUP), instanceOf(VolumeGroupWidget.class));
- assertThat(Widget.getWidget(Type.LINT), instanceOf(LIntfWidget.class));
- assertThat(Widget.getWidget(Type.L3_NET), instanceOf(L3NetworkWidget.class));
- assertThat(Widget.getWidget(Type.VFMODULE), instanceOf(VfModuleWidget.class));
- assertThat(Widget.getWidget(Type.IMAGE), instanceOf(ImageWidget.class));
- assertThat(Widget.getWidget(Type.OAM_NETWORK), instanceOf(OamNetwork.class));
- assertThat(Widget.getWidget(Type.ALLOTTED_RESOURCE), instanceOf(AllotedResourceWidget.class));
- assertThat(Widget.getWidget(Type.TUNNEL_XCONNECT), instanceOf(TunnelXconnectWidget.class));
- assertThat(Widget.getWidget(Type.CONFIGURATION), instanceOf(ConfigurationWidget.class));
+ public void testGetWidgets() throws XmlArtifactGenerationException {
+ Widget widget = Widget.getWidget(Type.SERVICE);
+ assertThat(widget.getType(), is(ModelType.WIDGET));
+ assertThat(widget.getName(), is("service-instance"));
+ assertThat(widget.getDeleteFlag(), is(true));
+
+ widget = Widget.getWidget(Type.VF);
+ assertThat(widget.getType(), is(ModelType.WIDGET));
+ assertThat(widget.getName(), is("generic-vnf"));
+ assertThat(widget.getDeleteFlag(), is(false));
+
+ widget = Widget.getWidget(Type.VFC);
+ assertThat(widget.getType(), is(ModelType.WIDGET));
+ assertThat(widget.getName(), is("vnfc"));
+ assertThat(widget.getDeleteFlag(), is(true));
+
+ widget = Widget.getWidget(Type.VSERVER);
+ assertThat(widget.getType(), is(ModelType.WIDGET));
+ assertThat(widget.getName(), is("vserver"));
+ assertThat(widget.getDeleteFlag(), is(true));
+
+ widget = Widget.getWidget(Type.VOLUME);
+ assertThat(widget.getType(), is(ModelType.WIDGET));
+ assertThat(widget.getName(), is("volume"));
+ assertThat(widget.getDeleteFlag(), is(true));
+
+ widget = Widget.getWidget(Type.FLAVOR);
+ assertThat(widget.getType(), is(ModelType.WIDGET));
+ assertThat(widget.getName(), is("flavor"));
+ assertThat(widget.getDeleteFlag(), is(false));
+
+ widget = Widget.getWidget(Type.TENANT);
+ assertThat(widget.getType(), is(ModelType.WIDGET));
+ assertThat(widget.getName(), is("tenant"));
+ assertThat(widget.getDeleteFlag(), is(false));
+
+ widget = Widget.getWidget(Type.VOLUME_GROUP);
+ assertThat(widget.getType(), is(ModelType.WIDGET));
+ assertThat(widget.getName(), is("volume-group"));
+ assertThat(widget.getDeleteFlag(), is(true));
+
+ widget = Widget.getWidget(Type.LINT);
+ assertThat(widget.getType(), is(ModelType.WIDGET));
+ assertThat(widget.getName(), is("l-interface"));
+ assertThat(widget.getDeleteFlag(), is(true));
+
+ widget = Widget.getWidget(Type.L3_NET);
+ assertThat(widget.getType(), is(ModelType.WIDGET));
+ assertThat(widget.getName(), is("l3-network"));
+ assertThat(widget.getDeleteFlag(), is(true));
+
+ widget = Widget.getWidget(Type.VFMODULE);
+ assertThat(widget.getType(), is(ModelType.WIDGET));
+ assertThat(widget.getName(), is("vf-module"));
+ assertThat(widget.getDeleteFlag(), is(true));
+
+ widget = Widget.getWidget(Type.IMAGE);
+ assertThat(widget.getType(), is(ModelType.WIDGET));
+ assertThat(widget.getName(), is("image"));
+ assertThat(widget.getDeleteFlag(), is(false));
+
+ widget = Widget.getWidget(Type.OAM_NETWORK);
+ assertThat(widget.getType(), is(ModelType.WIDGET));
+ assertThat(widget.getName(), is("oam-network"));
+ assertThat(widget.getDeleteFlag(), is(true));
+
+ widget = Widget.getWidget(Type.ALLOTTED_RESOURCE);
+ assertThat(widget.getType(), is(ModelType.WIDGET));
+ assertThat(widget.getName(), is("allotted-resource"));
+ assertThat(widget.getDeleteFlag(), is(true));
+
+ widget = Widget.getWidget(Type.TUNNEL_XCONNECT);
+ assertThat(widget.getType(), is(ModelType.WIDGET));
+ assertThat(widget.getName(), is("tunnel-xconnect"));
+ assertThat(widget.getDeleteFlag(), is(true));
+
+ widget = Widget.getWidget(Type.CONFIGURATION);
+ assertThat(widget.getType(), is(ModelType.WIDGET));
+ assertThat(widget.getName(), is("configuration"));
+ assertThat(widget.getDeleteFlag(), is(true));
}
@Test
- public void testWidgetMethods() {
- Widget widget = new ServiceWidget();
+ public void testWidgetMethods() throws XmlArtifactGenerationException {
+ Widget widget = new Widget(Type.SERVICE, "service-instance", true);
assertThat(widget.getType(), is(ModelType.WIDGET));
assertThat(widget.getWidgetId(), is("service-instance-invariant-id"));
- assertThat(widget.addWidget(new TenantWidget()), is(true));
+ assertThat(widget.addWidget(Widget.getWidget(Type.TENANT)), is(true));
assertThat(widget.memberOf(null), is(false));
assertThat(widget.memberOf(Collections.emptyList()), is(false));
-
- widget = new VolumeGroupWidget(); // just for variety
- assertThat(widget.getWidgetType(), is(nullValue()));
}
@Test(expected = org.onap.aai.babel.xml.generator.error.IllegalAccessException.class)
- public void testAddResourceIsUnsupported() {
- new OamNetwork().addResource(null);
+ public void testAddResourceIsUnsupported() throws XmlArtifactGenerationException {
+ Widget.getWidget(Type.OAM_NETWORK).addResource(null);
}
}
diff --git a/src/test/resources/empty-tosca-mappings.json b/src/test/resources/empty-tosca-mappings.json
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/test/resources/empty-tosca-mappings.json
diff --git a/src/test/resources/invalid-tosca-mappings.json b/src/test/resources/invalid-tosca-mappings.json
new file mode 100644
index 0000000..bbd27bd
--- /dev/null
+++ b/src/test/resources/invalid-tosca-mappings.json
@@ -0,0 +1 @@
+test file that does not contain valid JSON content \ No newline at end of file
diff --git a/src/test/resources/tosca-mappings.json b/src/test/resources/tosca-mappings.json
index 0d306ea..c67b3e2 100644
--- a/src/test/resources/tosca-mappings.json
+++ b/src/test/resources/tosca-mappings.json
@@ -4,6 +4,98 @@
"org.openecomp.groups.VfcInstanceGroup",
"org.openecomp.groups.ResourceInstanceGroup"
],
+ "widgetTypes": [
+ {
+ "type": "SERVICE",
+ "name": "service-instance",
+ "deleteFlag": true
+ },
+ {
+ "type": "VF",
+ "name": "generic-vnf",
+ "deleteFlag": false
+ },
+ {
+ "type": "VFC",
+ "name": "vnfc",
+ "deleteFlag": true
+ },
+ {
+ "type": "VSERVER",
+ "name": "vserver",
+ "deleteFlag": true
+ },
+ {
+ "type": "VOLUME",
+ "name": "volume",
+ "deleteFlag": true
+ },
+ {
+ "type": "FLAVOR",
+ "name": "flavor",
+ "deleteFlag": false
+ },
+ {
+ "type": "TENANT",
+ "name": "tenant",
+ "deleteFlag": false
+ },
+ {
+ "type": "VOLUME_GROUP",
+ "name": "volume-group",
+ "deleteFlag": true
+ },
+ {
+ "type": "LINT",
+ "name": "l-interface",
+ "deleteFlag": true
+ },
+ {
+ "type": "L3_NET",
+ "name": "l3-network",
+ "deleteFlag": true
+ },
+ {
+ "type": "VFMODULE",
+ "name": "vf-module",
+ "deleteFlag": true
+ },
+ {
+ "type": "IMAGE",
+ "name": "image",
+ "deleteFlag": false
+ },
+ {
+ "type": "OAM_NETWORK",
+ "name": "oam-network",
+ "deleteFlag": true
+ },
+ {
+ "type": "ALLOTTED_RESOURCE",
+ "name": "allotted-resource",
+ "deleteFlag": true
+ },
+ {
+ "type": "TUNNEL_XCONNECT",
+ "name": "tunnel-xconnect",
+ "deleteFlag": true
+ },
+ {
+ "type": "CONFIGURATION",
+ "name": "configuration",
+ "deleteFlag": true
+ },
+ {
+ "type": "CR",
+ "name": "cr",
+ "deleteFlag": true
+ },
+ {
+ "type": "INSTANCE_GROUP",
+ "name": "instance-group",
+ "deleteFlag": true
+ }
+ ],
"widgetMappings": [
{
"prefix": "org.openecomp.resource.vfc",