aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authormark.j.leonard <mark.j.leonard@gmail.com>2019-02-11 17:44:17 +0000
committermark.j.leonard <mark.j.leonard@gmail.com>2019-02-11 18:16:08 +0000
commitfc779f51a624bfddc68328bf3fd3c74594ef31f6 (patch)
tree397e3aa3e0f225b01a9845537e8ea2f8cfacf4ec /src/test
parenta583d474260f071cb2ee465ec76a277240575a21 (diff)
Rename the groupfilter.config System Property
Rename the System Property to be tosca.mappings.config and default the value to ${CONFIG_HOME}/tosca-mappings.json Update Java code and comments to remove the word "filter" where this is now outdated. Add new JUnit tests for better code coverage. Change-Id: Iaa9685638e099c898894171a958b0d5d51542fde Issue-ID: AAI-2121 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.java30
-rw-r--r--src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.java10
-rw-r--r--src/test/java/org/onap/aai/babel/util/ArtifactTestUtils.java4
-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.java8
5 files changed, 40 insertions, 14 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 d7519c0..a538373 100644
--- a/src/test/java/org/onap/aai/babel/parser/TestArtifactGeneratorToscaParser.java
+++ b/src/test/java/org/onap/aai/babel/parser/TestArtifactGeneratorToscaParser.java
@@ -2,8 +2,8 @@
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 European Software Marketing Ltd.
+ * Copyright © 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2019 European Software Marketing Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@ import java.util.List;
import org.junit.Test;
import org.mockito.Mockito;
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;
import org.onap.aai.babel.xml.generator.model.Widget.Type;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
@@ -59,7 +60,6 @@ public class TestArtifactGeneratorToscaParser {
}
/**
- *
* Add a CR (a type of Resource which is not a Providing Service) to a Resource Model.
*/
@Test(expected = IllegalArgumentException.class)
@@ -71,6 +71,26 @@ public class TestArtifactGeneratorToscaParser {
}
/**
+ * Initialise the Artifact Generator Widget Mapping config with incomplete data.
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void testToscaMappingWithoutType() {
+ WidgetMapping invalidMapping = new WidgetMapping();
+ invalidMapping.setType(null);
+ WidgetConfigurationUtil.setWidgetMappings(Collections.singletonList(invalidMapping));
+ }
+
+ /**
+ * Initialise the Artifact Generator Widget Mapping config with incomplete data.
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void testToscaMappingWithoutWidget() {
+ WidgetMapping invalidMapping = new WidgetMapping();
+ invalidMapping.setWidget(null);
+ WidgetConfigurationUtil.setWidgetMappings(Collections.singletonList(invalidMapping));
+ }
+
+ /**
* Process a dummy Group object for a Service Resource.
*/
@Test
@@ -104,9 +124,9 @@ public class TestArtifactGeneratorToscaParser {
* sdc-tosca parser.
*
* @param name
- * name of the NodeTemplate
+ * name of the NodeTemplate
* @param type
- * type of the NodeTemplate
+ * type of the NodeTemplate
* @return a new NodeTemplate object
*/
private NodeTemplate buildNodeTemplate(String name, String type) {
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 bcd1e8a..4921490 100644
--- a/src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.java
+++ b/src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.java
@@ -126,7 +126,7 @@ public class CsarToXmlConverterTest {
}
/**
- * Test that an Exception is thrown when the Artifact Generator's Group Filter properties are not present.
+ * Test that an Exception is thrown when the Artifact Generator's TOSCA Mappings configuration file is not present.
*
* @throws CsarConverterException
* if there is an error either extracting the YAML files or generating XML artifacts
@@ -134,13 +134,13 @@ public class CsarToXmlConverterTest {
* if an I/O exception occurs
*/
@Test
- public void generateXmlFromCsarFilterTypesSystemPropertyNotSet() throws CsarConverterException, IOException {
- exception.expect(CsarConverterException.class);
+ public void generateXmlFromCsarMappingSystemPropertyNotSet() throws CsarConverterException, IOException {
+ exception.expect(IllegalArgumentException.class);
exception.expectMessage("Cannot generate artifacts. System property "
- + ArtifactGeneratorToscaParser.PROPERTY_GROUP_FILTERS_CONFIG_FILE + " not configured");
+ + ArtifactGeneratorToscaParser.PROPERTY_TOSCA_MAPPING_FILE + " not configured");
// Unset the required system property
- System.clearProperty(ArtifactGeneratorToscaParser.PROPERTY_GROUP_FILTERS_CONFIG_FILE);
+ System.clearProperty(ArtifactGeneratorToscaParser.PROPERTY_TOSCA_MAPPING_FILE);
converter.generateXmlFromCsar(CsarTest.SD_WAN_CSAR_FILE.getContent(), CsarTest.SD_WAN_CSAR_FILE.getName(),
SERVICE_VERSION);
}
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 445dd84..01f62cf 100644
--- a/src/test/java/org/onap/aai/babel/util/ArtifactTestUtils.java
+++ b/src/test/java/org/onap/aai/babel/util/ArtifactTestUtils.java
@@ -63,8 +63,8 @@ public class ArtifactTestUtils {
System.setProperty(ArtifactGeneratorToscaParser.PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE,
getResourcePath(Resources.ARTIFACT_GENERATOR_CONFIG));
- System.setProperty(ArtifactGeneratorToscaParser.PROPERTY_GROUP_FILTERS_CONFIG_FILE,
- getResourcePath(Resources.FILTER_TYPES_CONFIG));
+ System.setProperty(ArtifactGeneratorToscaParser.PROPERTY_TOSCA_MAPPING_FILE,
+ getResourcePath(Resources.TOSCA_MAPPING_CONFIG));
}
/**
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 199b3cd..bbd663d 100644
--- a/src/test/java/org/onap/aai/babel/util/Resources.java
+++ b/src/test/java/org/onap/aai/babel/util/Resources.java
@@ -26,6 +26,6 @@ package org.onap.aai.babel.util;
public class Resources {
public static final String ARTIFACT_GENERATOR_CONFIG = "artifact-generator.properties";
- public static final String FILTER_TYPES_CONFIG = "tosca-mappings.json";
+ public static final String TOSCA_MAPPING_CONFIG = "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 3d5e841..8d1a045 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
@@ -65,7 +65,13 @@ public class TestModel {
ArtifactTestUtils utils = new ArtifactTestUtils();
utils.setGeneratorSystemProperties();
- ArtifactGeneratorToscaParser.initGroupFilterConfiguration();
+ String configLocation = System.getProperty(ArtifactGeneratorToscaParser.PROPERTY_TOSCA_MAPPING_FILE);
+ if (configLocation == null) {
+ throw new IllegalArgumentException(
+ String.format(ArtifactGeneratorToscaParser.GENERATOR_AAI_CONFIGLOCATION_NOT_FOUND, ArtifactGeneratorToscaParser.PROPERTY_TOSCA_MAPPING_FILE));
+ }
+
+ ArtifactGeneratorToscaParser.initToscaMappingsConfiguration(configLocation);
utils.loadWidgetToUuidMappings();
anonymousModel = new Model() {