Load type mappings from a group configuration file
Change the filter-types.properties file: re-implement to use JSON
content. Remove the System Property that defines the location of the
file and add this to the Spring application properties.
Initialise the type-to-model mappings using the key=value pairs from
this JSON content.
Refactor existing Junit tests to remove duplicated resource loading
code.
Change-Id: Idb2e962fe5cae39b70cc8cf16053d0a253f4fac0
Issue-ID: AAI-2121
Signed-off-by: mark.j.leonard <mark.j.leonard@gmail.com>
diff --git a/pom.xml b/pom.xml
index 3f6b7e3..0798d5c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -143,7 +143,7 @@
<artifactId>rest-client</artifactId>
<version>${aai.rest.client.version}</version>
</dependency>
-
+
<!-- Testing -->
<dependency>
<groupId>org.springframework.boot</groupId>
@@ -176,7 +176,6 @@
-DCONFIG_HOME=./appconfig-local
-DAPP_HOME=.
-Dartifactgenerator.config=./appconfig-local/artifact-generator.properties
- -Dgroupfilter.config=./appconfig-local/filter-types.properties
-DKEY_STORE_PASSWORD=${KEY_STORE_PASSWORD}
</jvmArguments>
</configuration>
diff --git a/src/main/bin/start.sh b/src/main/bin/start.sh
index c71acca..1ee1db6 100644
--- a/src/main/bin/start.sh
+++ b/src/main/bin/start.sh
@@ -3,8 +3,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.
@@ -34,7 +34,6 @@
PROPS="-DAPP_HOME=${APP_HOME}"
PROPS="${PROPS} -DCONFIG_HOME=${CONFIG_HOME}"
PROPS="${PROPS} -Dartifactgenerator.config=${CONFIG_HOME}/artifact-generator.properties"
-PROPS="${PROPS} -Dgroupfilter.config=${CONFIG_HOME}/filter-types.properties"
PROPS="${PROPS} -DKEY_STORE_PASSWORD=${KEY_STORE_PASSWORD}"
JVM_MAX_HEAP=${MAX_HEAP:-1024}
diff --git a/src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java b/src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java
index 615ad1e..505afbf 100644
--- a/src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java
+++ b/src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.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.
@@ -20,8 +20,12 @@
*/
package org.onap.aai.babel.parser;
+import com.google.gson.Gson;
+import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -32,6 +36,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.onap.aai.babel.logging.LogHelper;
+import org.onap.aai.babel.xml.generator.data.GroupConfiguration;
import org.onap.aai.babel.xml.generator.data.WidgetConfigurationUtil;
import org.onap.aai.babel.xml.generator.model.AllotedResource;
import org.onap.aai.babel.xml.generator.model.InstanceGroup;
@@ -82,7 +87,7 @@
* Constructs using csarHelper
*
* @param csarHelper
- * The csar helper
+ * The csar helper
*/
public ArtifactGeneratorToscaParser(ISdcCsarHelper csarHelper) {
this.csarHelper = csarHelper;
@@ -92,7 +97,7 @@
* Get or create the artifact description.
*
* @param model
- * the artifact model
+ * the artifact model
* @return the artifact model's description
*/
public static String getArtifactDescription(Model model) {
@@ -130,26 +135,28 @@
}
/**
- * Initialises the group filter configuration.
+ * Initialises the group filtering and mapping configuration.
+ *
+ * @throws FileNotFoundException
*
- * @throws IOException
*/
- public static void initGroupFilterConfiguration() throws IOException {
- log.debug("Getting Filter Tyoes Configuration");
+ public static void initGroupFilterConfiguration() throws FileNotFoundException {
+ log.debug("Getting Filter Types Configuration");
String configLocation = System.getProperty(PROPERTY_GROUP_FILTERS_CONFIG_FILE);
- if (configLocation != null) {
- File file = new File(configLocation);
- if (file.exists()) {
- Properties properties = new Properties();
- properties.load(new FileInputStream(file));
- WidgetConfigurationUtil.setFilterConfig(properties);
- } else {
- throw new IllegalArgumentException(String.format(GENERATOR_AAI_CONFIGFILE_NOT_FOUND, configLocation));
- }
- } else {
+ if (configLocation == null) {
throw new IllegalArgumentException(
String.format(GENERATOR_AAI_CONFIGLOCATION_NOT_FOUND, PROPERTY_GROUP_FILTERS_CONFIG_FILE));
}
+
+ File file = new File(configLocation);
+ if (!file.exists()) {
+ throw new IllegalArgumentException(String.format(GENERATOR_AAI_CONFIGFILE_NOT_FOUND, configLocation));
+ }
+
+ BufferedReader bufferedReader = new BufferedReader(new FileReader(configLocation));
+ GroupConfiguration config = new Gson().fromJson(bufferedReader, GroupConfiguration.class);
+ WidgetConfigurationUtil.setSupportedInstanceGroups(config.getInstanceGroupTypes());
+ WidgetConfigurationUtil.setTypeMappings(config.getToscaToWidgetMappings());
}
/**
@@ -178,9 +185,9 @@
* duplicate keys then the TOSCA Property value takes precedence.
*
* @param stringProps
- * initial Map of String property values (e.g. from the TOSCA YAML metadata section)
+ * initial Map of String property values (e.g. from the TOSCA YAML metadata section)
* @param toscaProps
- * Map of TOSCA Property Type Object values to merge in (or overwrite)
+ * Map of TOSCA Property Type Object values to merge in (or overwrite)
* @return a Map of the property values converted to String
*/
public Map<String, String> mergeProperties(Map<String, String> stringProps, Map<String, Property> toscaProps) {
@@ -278,13 +285,13 @@
* Create an Instance Group Model and populate it with the supplied data.
*
* @param resourceModel
- * the Resource node template Model
+ * the Resource node template Model
* @param memberNodes
- * the Resources and Widgets belonging to the Group
+ * the Resources and Widgets belonging to the Group
* @param metaProperties
- * the metadata of the Group
+ * the metadata of the Group
* @param properties
- * the properties of the Group
+ * the properties of the Group
* @return the Instance Group and Member resource models
*/
private List<Resource> processInstanceGroup(Model resourceModel, ArrayList<NodeTemplate> memberNodes,
@@ -379,7 +386,7 @@
* Create a Map of property name against String property value from the input Map
*
* @param inputMap
- * The input Map
+ * The input Map
* @return Map of property name against String property value
*/
private Map<String, String> populateStringProperties(Map<String, Property> inputMap) {
@@ -392,13 +399,13 @@
* is ProvidingService return true, otherwise return false.
*
* @param resourceModel
- * parent Resource
+ * parent Resource
* @param metaData
- * for populating the Resource IDs
+ * for populating the Resource IDs
* @param resourceNode
- * any Model (will be ignored if not a Resource)
+ * any Model (will be ignored if not a Resource)
* @param nodeProperties
- * the node properties
+ * the node properties
* @return whether or not a ProvidingService was prcoessed
*/
private boolean processModel(Model resourceModel, Metadata metaData, Model resourceNode,
diff --git a/src/main/java/org/onap/aai/babel/xml/generator/api/AaiArtifactGenerator.java b/src/main/java/org/onap/aai/babel/xml/generator/api/AaiArtifactGenerator.java
index 531a044..d6d0a1e 100644
--- a/src/main/java/org/onap/aai/babel/xml/generator/api/AaiArtifactGenerator.java
+++ b/src/main/java/org/onap/aai/babel/xml/generator/api/AaiArtifactGenerator.java
@@ -102,7 +102,7 @@
*
* @param serviceVersion
* @param csarHelper
- * interface to the TOSCA parser
+ * interface to the TOSCA parser
* @return the generated Artifacts (containing XML models)
*/
private GenerationData generateAllArtifacts(final String serviceVersion, ISdcCsarHelper csarHelper) {
@@ -265,7 +265,7 @@
* Method to generate the artifact name for an AAI model.
*
* @param model
- * AAI artifact model
+ * AAI artifact model
* @return Model artifact name
*/
private String getArtifactName(Model model) {
@@ -289,9 +289,9 @@
* Create Resource artifact model from the AAI xml model string.
*
* @param resourceModel
- * Model of the resource artifact
+ * Model of the resource artifact
* @param aaiResourceModel
- * AAI model as string
+ * AAI model as string
* @return Generated {@link Artifact} model for the resource
*/
private Artifact getResourceArtifact(Model resourceModel, String aaiResourceModel) {
@@ -321,9 +321,9 @@
* Create Service artifact model from the AAI XML model.
*
* @param serviceModel
- * Model of the service artifact
+ * Model of the service artifact
* @param aaiServiceModel
- * AAI model as string
+ * AAI model as string
* @return Generated {@link Artifact} model for the service
*/
private Artifact getServiceArtifact(Service serviceModel, String aaiServiceModel) {
diff --git a/src/main/java/org/onap/aai/babel/xml/generator/data/GroupConfiguration.java b/src/main/java/org/onap/aai/babel/xml/generator/data/GroupConfiguration.java
new file mode 100644
index 0000000..9223f27
--- /dev/null
+++ b/src/main/java/org/onap/aai/babel/xml/generator/data/GroupConfiguration.java
@@ -0,0 +1,45 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * 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.
+ * 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.onap.aai.babel.xml.generator.data;
+
+import java.util.List;
+import java.util.Map;
+
+public class GroupConfiguration {
+
+ /**
+ * Names of Instance Groups that will be processed (not filtered out).
+ */
+ private List<String> instanceGroupTypes;
+
+ /**
+ * Mapping from TOSCA type to Widget Model.
+ */
+ private Map<String, String> toscaToWidgetMappings;
+
+ public List<String> getInstanceGroupTypes() {
+ return instanceGroupTypes;
+ }
+
+ public Map<String, String> getToscaToWidgetMappings() {
+ return toscaToWidgetMappings;
+ }
+}
diff --git a/src/main/java/org/onap/aai/babel/xml/generator/data/WidgetConfigurationUtil.java b/src/main/java/org/onap/aai/babel/xml/generator/data/WidgetConfigurationUtil.java
index 9f8cbf8..30b6c8e 100644
--- a/src/main/java/org/onap/aai/babel/xml/generator/data/WidgetConfigurationUtil.java
+++ b/src/main/java/org/onap/aai/babel/xml/generator/data/WidgetConfigurationUtil.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.
@@ -20,15 +20,19 @@
*/
package org.onap.aai.babel.xml.generator.data;
-import java.util.Arrays;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.Properties;
+import org.onap.aai.babel.xml.generator.model.Model;
public class WidgetConfigurationUtil {
private static Properties config;
private static List<String> instanceGroups = Collections.emptyList();
+ private static Map<String, Class<? extends Model>> typeToModel = new HashMap<>();
/*
* Private constructor to prevent instantiation
@@ -45,14 +49,38 @@
WidgetConfigurationUtil.config = config;
}
- public static void setFilterConfig(Properties properties) {
- String instanceGroupsList = (String) properties.get("AAI.instance-group-types");
- if (instanceGroupsList != null) {
- instanceGroups = Arrays.asList(instanceGroupsList.split(","));
- }
- }
+ public static void setSupportedInstanceGroups(List<String> supportedInstanceGroups) {
+ instanceGroups = supportedInstanceGroups;
+ }
public static boolean isSupportedInstanceGroup(String groupType) {
return instanceGroups.contains(groupType);
}
+
+ /**
+ * Create the mappings from TOSCA type to Widget type. The Properties store a set of TOSCA type prefix Strings.
+ * These keys take a single class name (String), which is used to map to a Widget Class in the Model.
+ *
+ * @param map
+ * the key/value pairs of TOSCA type and Class name
+ */
+ @SuppressWarnings("unchecked")
+ public static void setTypeMappings(Map<String, String> map) {
+ for (Entry<String, String> entry : map.entrySet()) {
+ final String toscaType = entry.getKey();
+ final String javaBean = entry.getValue();
+ final String modelClassName = Model.class.getPackage().getName() + "." + javaBean;
+ try {
+ typeToModel.put(toscaType, (Class<? extends Model>) Class.forName(modelClassName));
+ } catch (ClassNotFoundException e) {
+ throw new IllegalArgumentException(
+ String.format("Unsupported type \"%s\" for TOSCA mapping %s: no class found for %s", //
+ javaBean, toscaType, modelClassName));
+ }
+ }
+ }
+
+ public static Class<? extends Model> getModelFromType(String typePrefix) {
+ return typeToModel.get(typePrefix);
+ }
}
diff --git a/src/main/java/org/onap/aai/babel/xml/generator/model/Model.java b/src/main/java/org/onap/aai/babel/xml/generator/model/Model.java
index 7b2fc42..0e2b8d5 100644
--- a/src/main/java/org/onap/aai/babel/xml/generator/model/Model.java
+++ b/src/main/java/org/onap/aai/babel/xml/generator/model/Model.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.
@@ -29,6 +29,7 @@
import java.util.Set;
import org.onap.aai.babel.logging.ApplicationMsgs;
import org.onap.aai.babel.logging.LogHelper;
+import org.onap.aai.babel.xml.generator.data.WidgetConfigurationUtil;
import org.onap.aai.babel.xml.generator.error.IllegalAccessException;
import org.onap.aai.babel.xml.generator.types.Cardinality;
import org.onap.aai.babel.xml.generator.types.ModelType;
@@ -40,22 +41,6 @@
private static Logger log = LogHelper.INSTANCE;
- private static Map<String, Class<? extends Model>> typeToModel = new HashMap<>();
- static {
- typeToModel.put("org.openecomp.resource.vf.allottedResource", AllotedResource.class);
- typeToModel.put("org.openecomp.resource.vfc.AllottedResource", ProvidingService.class);
- typeToModel.put("org.openecomp.resource.vfc", VServerWidget.class);
- typeToModel.put("org.openecomp.resource.cp", LIntfWidget.class);
- typeToModel.put("org.openecomp.cp", LIntfWidget.class);
- typeToModel.put("org.openecomp.resource.vl", L3Network.class);
- typeToModel.put("org.openecomp.resource.vf", VirtualFunction.class);
- typeToModel.put("org.openecomp.groups.vfmodule", VfModule.class);
- typeToModel.put("org.openecomp.groups.VfModule", VfModule.class);
- typeToModel.put("org.openecomp.resource.vfc.nodes.heat.cinder", VolumeWidget.class);
- typeToModel.put("org.openecomp.nodes.PortMirroringConfiguration", Configuration.class);
- typeToModel.put("org.openecomp.resource.cr.Kk1806Cr1", CR.class);
- }
-
private enum ModelIdentification {
ID("vfModuleModelInvariantUUID", "serviceInvariantUUID", "resourceInvariantUUID", "invariantUUID",
"providing_service_invariant_uuid") {
@@ -154,7 +139,7 @@
private static Optional<Model> getModelFromType(String typePrefix) {
Optional<Model> modelToBeReturned = Optional.empty();
- Class<? extends Model> clazz = typeToModel.get(typePrefix);
+ Class<? extends Model> clazz = WidgetConfigurationUtil.getModelFromType(typePrefix);
if (clazz != null) {
try {
modelToBeReturned = Optional.ofNullable(clazz.getConstructor().newInstance());
@@ -197,8 +182,8 @@
* @return the cardinality
*/
public Cardinality getCardinality() {
- org.onap.aai.babel.xml.generator.types.Model model = this.getClass()
- .getAnnotation(org.onap.aai.babel.xml.generator.types.Model.class);
+ org.onap.aai.babel.xml.generator.types.Model model =
+ this.getClass().getAnnotation(org.onap.aai.babel.xml.generator.types.Model.class);
return model.cardinality();
}
@@ -208,8 +193,8 @@
* @return the delete flag
*/
public boolean getDeleteFlag() {
- org.onap.aai.babel.xml.generator.types.Model model = this.getClass()
- .getAnnotation(org.onap.aai.babel.xml.generator.types.Model.class);
+ org.onap.aai.babel.xml.generator.types.Model model =
+ this.getClass().getAnnotation(org.onap.aai.babel.xml.generator.types.Model.class);
return model.dataDeleteFlag();
}
@@ -258,8 +243,8 @@
* @return the widget version id
*/
public String getWidgetId() {
- org.onap.aai.babel.xml.generator.types.Model model = this.getClass()
- .getAnnotation(org.onap.aai.babel.xml.generator.types.Model.class);
+ org.onap.aai.babel.xml.generator.types.Model model =
+ this.getClass().getAnnotation(org.onap.aai.babel.xml.generator.types.Model.class);
return Widget.getWidget(model.widget()).getId();
}
@@ -269,8 +254,8 @@
* @return the invariant id
*/
public String getWidgetInvariantId() {
- org.onap.aai.babel.xml.generator.types.Model model = this.getClass()
- .getAnnotation(org.onap.aai.babel.xml.generator.types.Model.class);
+ org.onap.aai.babel.xml.generator.types.Model model =
+ this.getClass().getAnnotation(org.onap.aai.babel.xml.generator.types.Model.class);
return Widget.getWidget(model.widget()).getWidgetId();
}
diff --git a/src/main/java/org/onap/aai/babel/xml/generator/model/Widget.java b/src/main/java/org/onap/aai/babel/xml/generator/model/Widget.java
index d78e2e6..963d9e2 100644
--- a/src/main/java/org/onap/aai/babel/xml/generator/model/Widget.java
+++ b/src/main/java/org/onap/aai/babel/xml/generator/model/Widget.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.
@@ -109,8 +109,7 @@
}
public String getId() {
- Properties properties = WidgetConfigurationUtil.getConfig();
- String id = properties.getProperty(ArtifactType.AAI.name() + ".model-version-id." + getName());
+ String id = WidgetConfigurationUtil.getConfig().getProperty(ArtifactType.AAI.name() + ".model-version-id." + getName());
if (id == null) {
throw new IllegalArgumentException(String.format(GENERATOR_AAI_CONFIGLPROP_NOT_FOUND,
ArtifactType.AAI.name() + ".model-version-id." + getName()));
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 2cb4fe8..c9982d6 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -4,4 +4,6 @@
server.contextPath=/services/babel-service
-logging.config=${CONFIG_HOME}/logback.xml
\ No newline at end of file
+logging.config=${CONFIG_HOME}/logback.xml
+
+groupfilter.config=${CONFIG_HOME}/tosca-mappings.json
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 b7957f7..52dd462 100644
--- a/src/test/java/org/onap/aai/babel/parser/TestArtifactGeneratorToscaParser.java
+++ b/src/test/java/org/onap/aai/babel/parser/TestArtifactGeneratorToscaParser.java
@@ -29,7 +29,6 @@
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
-import java.util.Properties;
import org.junit.Test;
import org.mockito.Mockito;
import org.onap.aai.babel.xml.generator.data.WidgetConfigurationUtil;
@@ -76,9 +75,7 @@
@Test
public void testInstanceGroups() {
final String instanceGroupType = "org.openecomp.groups.ResourceInstanceGroup";
- Properties props = new Properties();
- props.put("AAI.instance-group-types", instanceGroupType);
- WidgetConfigurationUtil.setFilterConfig(props);
+ WidgetConfigurationUtil.setSupportedInstanceGroups(Collections.singletonList(instanceGroupType));
ISdcCsarHelper helper = Mockito.mock(ISdcCsarHelper.class);
SubstitutionMappings sm = Mockito.mock(SubstitutionMappings.class);
@@ -105,9 +102,9 @@
* 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/parser/TestToscaParser.java b/src/test/java/org/onap/aai/babel/parser/TestToscaParser.java
index 3bab915..f8d8478 100644
--- a/src/test/java/org/onap/aai/babel/parser/TestToscaParser.java
+++ b/src/test/java/org/onap/aai/babel/parser/TestToscaParser.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.
@@ -24,13 +24,10 @@
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-import java.io.FileNotFoundException;
import java.io.IOException;
-import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
import org.junit.Before;
import org.junit.Test;
import org.onap.aai.babel.csar.extractor.InvalidArchiveException;
@@ -40,10 +37,9 @@
import org.onap.aai.babel.xml.generator.data.AdditionalParams;
import org.onap.aai.babel.xml.generator.data.Artifact;
import org.onap.aai.babel.xml.generator.data.GenerationData;
-import org.onap.aai.babel.xml.generator.data.WidgetConfigurationUtil;
/**
- * Direct tests of the Model to improve code coverage.
+ * Direct tests of the {@link AaiArtifactGenerator} to improve code coverage.
*/
public class TestToscaParser {
@@ -53,22 +49,9 @@
}
}
- private static final String ARTIFACT_GENERATOR_CONFIG = "artifact-generator.properties";
- private static final String FILTER_TYPES_CONFIG = "filter-types.properties";
-
@Before
- public void setup() throws FileNotFoundException, IOException {
- System.setProperty(ArtifactGeneratorToscaParser.PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE,
- new ArtifactTestUtils().getResourcePath(ARTIFACT_GENERATOR_CONFIG));
-
- System.setProperty(ArtifactGeneratorToscaParser.PROPERTY_GROUP_FILTERS_CONFIG_FILE,
- new ArtifactTestUtils().getResourcePath(FILTER_TYPES_CONFIG));
-
- InputStream in = TestToscaParser.class.getClassLoader().getResourceAsStream("artifact-generator.properties");
- Properties properties = new Properties();
- properties.load(in);
- in.close();
- WidgetConfigurationUtil.setConfig(properties);
+ public void setup() {
+ new ArtifactTestUtils().setGeneratorSystemProperties();
}
@Test
@@ -78,8 +61,8 @@
additionalParams.put(AdditionalParams.SERVICE_VERSION.getName(), "1.0");
AaiArtifactGenerator generator = new AaiArtifactGenerator();
- GenerationData data = generator.generateArtifact(CsarTest.VNF_VENDOR_CSAR.getContent(), ymlFiles,
- additionalParams);
+ GenerationData data =
+ generator.generateArtifact(CsarTest.VNF_VENDOR_CSAR.getContent(), ymlFiles, additionalParams);
assertThat(data.getErrorData().size(), is(equalTo(0)));
assertThat(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 1d39f6d..1ead8e6 100644
--- a/src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.java
+++ b/src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.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.
@@ -54,9 +54,6 @@
*/
public class CsarToXmlConverterTest {
- private static final String ARTIFACT_GENERATOR_CONFIG = "artifact-generator.properties";
- private static final String FILTER_TYPES_CONFIG = "filter-types.properties";
-
private static final String INCORRECT_CSAR_NAME = "the_name_of_the_csar_file.csar";
private static final String SERVICE_VERSION = "1.0";
@@ -74,12 +71,7 @@
@Before
public void setup() {
- System.setProperty(ArtifactGeneratorToscaParser.PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE,
- new ArtifactTestUtils().getResourcePath(ARTIFACT_GENERATOR_CONFIG));
-
- System.setProperty(ArtifactGeneratorToscaParser.PROPERTY_GROUP_FILTERS_CONFIG_FILE,
- new ArtifactTestUtils().getResourcePath(FILTER_TYPES_CONFIG));
-
+ new ArtifactTestUtils().setGeneratorSystemProperties();
converter = new CsarToXmlConverter();
}
@@ -118,9 +110,9 @@
* Test that an Exception is thrown when the Artifact Generator properties are not present.
*
* @throws CsarConverterException
- * if there is an error either extracting the YAML files or generating XML artifacts
+ * if there is an error either extracting the YAML files or generating XML artifacts
* @throws IOException
- * if an I/O exception occurs loading the test CSAR file
+ * if an I/O exception occurs loading the test CSAR file
* @throws IOException
* @throws XmlArtifactGenerationException
* @throws CsarConverterException
@@ -147,7 +139,8 @@
public void generateXmlFromCsarFilterTypesSystemPropertyNotSet()
throws IOException, XmlArtifactGenerationException, CsarConverterException {
exception.expect(CsarConverterException.class);
- exception.expectMessage("Cannot generate artifacts. System property groupfilter.config not configured");
+ exception.expectMessage("Cannot generate artifacts. System property "
+ + ArtifactGeneratorToscaParser.PROPERTY_GROUP_FILTERS_CONFIG_FILE + " not configured");
// Unset the required system property
System.clearProperty(ArtifactGeneratorToscaParser.PROPERTY_GROUP_FILTERS_CONFIG_FILE);
diff --git a/src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java b/src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java
index 78e02f4..d87f3c3 100644
--- a/src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java
+++ b/src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.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.
@@ -18,6 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.babel.service;
import static org.hamcrest.Matchers.is;
@@ -42,7 +43,6 @@
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.onap.aai.auth.AAIMicroServiceAuth;
-import org.onap.aai.babel.parser.ArtifactGeneratorToscaParser;
import org.onap.aai.babel.service.data.BabelRequest;
import org.onap.aai.babel.testdata.CsarTest;
import org.onap.aai.babel.util.ArtifactTestUtils;
@@ -55,7 +55,7 @@
*
*/
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = { "classpath:/babel-beans.xml" })
+@ContextConfiguration(locations = {"classpath:/babel-beans.xml"})
public class TestGenerateArtifactsServiceImpl {
static {
@@ -65,18 +65,14 @@
System.setProperty("CONFIG_HOME", "src/test/resources");
}
- private static final String ARTIFACT_GENERATOR_CONFIG = "artifact-generator.properties";
- private static final String FILTER_TYPES_CONFIG = "filter-types.properties";
@Inject
private AAIMicroServiceAuth auth;
@BeforeClass
public static void setup() {
- System.setProperty(ArtifactGeneratorToscaParser.PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE,
- new ArtifactTestUtils().getResourcePath(ARTIFACT_GENERATOR_CONFIG));
- System.setProperty(ArtifactGeneratorToscaParser.PROPERTY_GROUP_FILTERS_CONFIG_FILE,
- new ArtifactTestUtils().getResourcePath(FILTER_TYPES_CONFIG));
+ new ArtifactTestUtils().setGeneratorSystemProperties();
+
}
@Test
@@ -199,7 +195,7 @@
Mockito.when(mockCertificate.getSubjectX500Principal())
.thenReturn(new X500Principal("CN=test, OU=qa, O=Test Ltd, L=London, ST=London, C=GB"));
- servletRequest.setAttribute("javax.servlet.request.X509Certificate", new X509Certificate[] { mockCertificate });
+ servletRequest.setAttribute("javax.servlet.request.X509Certificate", new X509Certificate[] {mockCertificate});
servletRequest.setAttribute("javax.servlet.request.cipher_suite", "");
GenerateArtifactsServiceImpl service = new GenerateArtifactsServiceImpl(auth);
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 fa0b784..6608c00 100644
--- a/src/test/java/org/onap/aai/babel/util/ArtifactTestUtils.java
+++ b/src/test/java/org/onap/aai/babel/util/ArtifactTestUtils.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.
@@ -18,6 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.babel.util;
import static org.hamcrest.CoreMatchers.equalTo;
@@ -27,6 +28,7 @@
import static org.junit.Assert.assertThat;
import java.io.IOException;
+import java.io.InputStream;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.Charset;
@@ -36,14 +38,17 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.stream.Collectors;
import org.apache.commons.io.IOUtils;
import org.custommonkey.xmlunit.Diff;
+import org.onap.aai.babel.parser.ArtifactGeneratorToscaParser;
import org.onap.aai.babel.xml.generator.data.Artifact;
+import org.onap.aai.babel.xml.generator.data.WidgetConfigurationUtil;
import org.xml.sax.SAXException;
/**
- * This class provides some utilities to assist with running tests.
+ * This class provides some utilities to assist with running local unit tests.
*/
public class ArtifactTestUtils {
@@ -51,15 +56,33 @@
private static final String JSON_RESPONSES_FOLDER = "response/";
private static final String CSAR_INPUTS_FOLDER = "compressedArtifacts/";
+ public void setGeneratorSystemProperties() {
+ 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));
+ }
+
+ /**
+ * Load the Widget to UUID mappings from the Artifact Generator Properties (resource).
+ *
+ * @throws IOException
+ * if the properties file is not loaded
+ */
+ public void loadWidgetToUuidMappings() throws IOException {
+ WidgetConfigurationUtil.setConfig(getResourceAsProperties(Resources.ARTIFACT_GENERATOR_CONFIG));
+ }
+
/**
* Specific test method for the YAML Extractor test.
*
* @param toscaFiles
- * files extracted by the YamlExtractor
+ * files extracted by the YamlExtractor
* @param ymlPayloadsToLoad
- * the expected YAML files
+ * the expected YAML files
* @throws IOException
- * if an I/O exception occurs
+ * if an I/O exception occurs
*/
public void performYmlAsserts(List<Artifact> toscaFiles, List<String> ymlPayloadsToLoad) throws IOException {
assertThat("An incorrect number of YAML files have been extracted", toscaFiles.size(),
@@ -83,14 +106,14 @@
* Compare two XML strings to see if they have the same content.
*
* @param string1
- * XML content
+ * XML content
* @param string2
- * XML content
+ * XML content
* @return true if XML content is similar
* @throws IOException
- * if an I/O exception occurs
+ * if an I/O exception occurs
* @throws SAXException
- * if the XML parsing fails
+ * if the XML parsing fails
*/
public boolean compareXmlStrings(String string1, String string2) throws SAXException, IOException {
return new Diff(string1, string2).similar();
@@ -120,6 +143,14 @@
return Files.lines(Paths.get(getResource(resourceFile).toURI())).collect(Collectors.joining());
}
+ public Properties getResourceAsProperties(String resourceName) throws IOException {
+ final Properties properties = new Properties();
+ InputStream in = ArtifactTestUtils.class.getClassLoader().getResourceAsStream(resourceName);
+ properties.load(in);
+ in.close();
+ return properties;
+ }
+
public String getResourcePath(String resourceName) {
return getResource(resourceName).getPath();
}
diff --git a/src/test/java/org/onap/aai/babel/util/Resources.java b/src/test/java/org/onap/aai/babel/util/Resources.java
new file mode 100644
index 0000000..199b3cd
--- /dev/null
+++ b/src/test/java/org/onap/aai/babel/util/Resources.java
@@ -0,0 +1,31 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * 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.
+ * 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.onap.aai.babel.util;
+
+/**
+ * Common Test resources.
+ */
+public class Resources {
+
+ public static final String ARTIFACT_GENERATOR_CONFIG = "artifact-generator.properties";
+ public static final String FILTER_TYPES_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 9b5700d..912a505 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
@@ -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.
@@ -26,15 +26,13 @@
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
-import java.io.FileNotFoundException;
import java.io.IOException;
-import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
-import java.util.Properties;
import org.junit.Before;
import org.junit.Test;
-import org.onap.aai.babel.xml.generator.data.WidgetConfigurationUtil;
+import org.onap.aai.babel.parser.ArtifactGeneratorToscaParser;
+import org.onap.aai.babel.util.ArtifactTestUtils;
import org.onap.aai.babel.xml.generator.model.Widget.Type;
import org.onap.aai.babel.xml.generator.types.ModelType;
@@ -54,20 +52,19 @@
}
/**
- * Load the Widget to UUID mappings from the Artifact Generator properties.
+ * Initialise the Artifact Generator with filtering and mapping configuration. Also Load the Widget to UUID mappings
+ * from the Artifact Generator properties.
*
- * @throws FileNotFoundException
- * if the properties file is missing
* @throws IOException
- * if the properties file is not loaded
+ * if the Artifact Generator properties file is not loaded
*/
@Before
- public void setup() throws FileNotFoundException, IOException {
- InputStream in = TestModel.class.getClassLoader().getResourceAsStream("artifact-generator.properties");
- Properties properties = new Properties();
- properties.load(in);
- in.close();
- WidgetConfigurationUtil.setConfig(properties);
+ public void setup() throws IOException {
+ ArtifactTestUtils utils = new ArtifactTestUtils();
+ utils.setGeneratorSystemProperties();
+
+ ArtifactGeneratorToscaParser.initGroupFilterConfiguration();
+ utils.loadWidgetToUuidMappings();
anonymousModel = new Model() {
@Override
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 e9c8c1b..1a5986b 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
@@ -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.
@@ -26,16 +26,13 @@
import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
import static org.junit.Assert.assertThat;
-import java.io.FileNotFoundException;
import java.io.IOException;
-import java.io.InputStream;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import java.util.Properties;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.onap.aai.babel.xml.generator.data.WidgetConfigurationUtil;
+import org.onap.aai.babel.util.ArtifactTestUtils;
import org.onap.aai.babel.xml.generator.model.Widget.Type;
/**
@@ -47,33 +44,39 @@
System.setProperty("APP_HOME", ".");
}
- /**
- * Load the Widget to UUID mappings from the Artifact Generator properties.
- *
- * @throws FileNotFoundException if the properties file is missing
- * @throws IOException if the properties file is not loaded
- */
@BeforeClass
- public static void setup() throws FileNotFoundException, IOException {
- InputStream in = TestVfModule.class.getClassLoader().getResourceAsStream("artifact-generator.properties");
- Properties properties = new Properties();
- properties.load(in);
- in.close();
- WidgetConfigurationUtil.setConfig(properties);
+ public static void setup() throws IOException {
+ new ArtifactTestUtils().loadWidgetToUuidMappings();
}
/**
- * Call equals() and hashCode() methods for code coverage.
+ * Call hashCode() method for code coverage.
*/
@Test
- public void testEqualsHashCode() {
+ public void testHashCode() {
VfModule vfModule = createNewVfModule();
populateIdentInfo(vfModule);
assertThat(vfModule.hashCode(), is(notNullValue()));
- assertThat(vfModule.equals(vfModule), is(true));
- // Tests that the overridden equals() method correctly returns false for a different type of Object
- // This is necessary to achieve complete code coverage
- assertThat(vfModule.equals("string"), is(false)); // NOSONAR
+ }
+
+ /**
+ * Call equals() method for code coverage.
+ */
+ @Test
+ public void testEquals() {
+ VfModule vfModuleA = createNewVfModule();
+ populateIdentInfo(vfModuleA);
+
+ // equals() is reflexive
+ assertThat(vfModuleA.equals(vfModuleA), is(true));
+
+ // equals() is symmetric
+ VfModule vfModuleB = createNewVfModule();
+ populateIdentInfo(vfModuleB);
+ assertThat(vfModuleA.equals(vfModuleB), is(true));
+ assertThat(vfModuleB.equals(vfModuleA), is(true));
+
+ assertThat(vfModuleA.equals(null), is(false));
}
@Test
@@ -216,7 +219,8 @@
/**
* Use the static Factory method to create a new Widget.
*
- * @param widgetType type of Widget to create
+ * @param widgetType
+ * type of Widget to create
* @return a new Widget
*/
private Widget createNewWidget(Type widgetType) {
@@ -237,7 +241,8 @@
/**
* Set up some dummy Model Identification properties.
*
- * @param vfModule to be populated
+ * @param vfModule
+ * to be populated
*/
private void populateIdentInfo(VfModule vfModule) {
Map<String, String> modelIdentInfo = new HashMap<>();
@@ -248,8 +253,10 @@
/**
* Create a new Widget and assert that it is successfully added to the VF Module.
*
- * @param vfModule the VF Module to update
- * @param widgetType the type of Widget to create and add
+ * @param vfModule
+ * the VF Module to update
+ * @param widgetType
+ * the type of Widget to create and add
*/
private void assertAddWidget(VfModule vfModule, Type widgetType) {
assertThat(createNewWidgetForModule(vfModule, widgetType), is(true));
@@ -258,8 +265,10 @@
/**
* Create a new Widget and assert that it cannot be added to the VF Module.
*
- * @param vfModule the VF Module
- * @param widgetType the type of Widget to create and attempt to add
+ * @param vfModule
+ * the VF Module
+ * @param widgetType
+ * the type of Widget to create and attempt to add
*/
private void assertFailToAddWidget(VfModule vfModule, Type widgetType) {
assertThat(createNewWidgetForModule(vfModule, widgetType), is(false));
@@ -268,8 +277,10 @@
/**
* Create a new widget, make it a member of the VF Module, then try to add it.
*
- * @param vfModule the VF Module to update
- * @param widgetType the type of Widget to create and attempt to add
+ * @param vfModule
+ * the VF Module to update
+ * @param widgetType
+ * the type of Widget to create and attempt to add
* @return whether or not the Widget was added to the module
*/
private boolean createNewWidgetForModule(VfModule vfModule, Type widgetType) {
@@ -283,8 +294,10 @@
* to its set of keys, and by then setting the VF Module's members to a Singleton List comprised of this ID. These
* updates allow the Widget to be successfully added to the VF Module. (Non-member Widgets cannot be added.)
*
- * @param vfModule the module for which members are overwritten
- * @param widget the widget to be set as the member
+ * @param vfModule
+ * the module for which members are overwritten
+ * @param widget
+ * the widget to be set as the member
*/
private void setWidgetAsMember(VfModule vfModule, Widget widget) {
String id = widget.getId();
@@ -295,7 +308,8 @@
/**
* Create a vserver widget and add it to the specified VF Module.
*
- * @param vfModule the VF Module to update
+ * @param vfModule
+ * the VF Module to update
* @return the number of Widgets present in the vserver on creation
*/
private int createVserverForVf(VfModule vfModule) {
@@ -309,8 +323,10 @@
/**
* Add the specified vserver to the specified VF Module.
*
- * @param vfModule the VF Module to update
- * @param vserverWidget the Widget to add
+ * @param vfModule
+ * the VF Module to update
+ * @param vserverWidget
+ * the Widget to add
* @return initial widget count for the vserver Widget
*/
private int addVserverToVf(VfModule vfModule, VServerWidget vserverWidget) {
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 212c221..d7fe4af 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
@@ -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.
@@ -26,14 +26,11 @@
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
-import java.io.FileNotFoundException;
import java.io.IOException;
-import java.io.InputStream;
import java.util.Collections;
-import java.util.Properties;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.onap.aai.babel.xml.generator.data.WidgetConfigurationUtil;
+import org.onap.aai.babel.util.ArtifactTestUtils;
import org.onap.aai.babel.xml.generator.model.Widget.Type;
import org.onap.aai.babel.xml.generator.types.ModelType;
@@ -49,18 +46,12 @@
/**
* Load the Widget to UUID mappings from the Artifact Generator properties.
*
- * @throws FileNotFoundException
- * if the properties file is missing
* @throws IOException
* if the properties file is not loaded
*/
@BeforeClass
- public static void setup() throws FileNotFoundException, IOException {
- final Properties properties = new Properties();
- try (InputStream in = TestWidget.class.getClassLoader().getResourceAsStream("artifact-generator.properties")) {
- properties.load(in);
- }
- WidgetConfigurationUtil.setConfig(properties);
+ public static void setup() throws IOException {
+ new ArtifactTestUtils().loadWidgetToUuidMappings();
}
@Test
diff --git a/src/test/resources/filter-types.properties b/src/test/resources/filter-types.properties
deleted file mode 100644
index 8577841..0000000
--- a/src/test/resources/filter-types.properties
+++ /dev/null
@@ -1 +0,0 @@
-AAI.instance-group-types=org.openecomp.groups.NetworkCollection,org.openecomp.groups.VfcInstanceGroup,org.openecomp.groups.ResourceInstanceGroup
diff --git a/src/test/resources/tosca-mappings.json b/src/test/resources/tosca-mappings.json
new file mode 100644
index 0000000..9c3d0b4
--- /dev/null
+++ b/src/test/resources/tosca-mappings.json
@@ -0,0 +1,21 @@
+{
+ "instanceGroupTypes": [
+ "org.openecomp.groups.NetworkCollection",
+ "org.openecomp.groups.VfcInstanceGroup",
+ "org.openecomp.groups.ResourceInstanceGroup"
+ ],
+ "toscaToWidgetMappings": {
+ "org.openecomp.resource.vf.allottedResource": "AllotedResource",
+ "org.openecomp.resource.vfc.AllottedResource": "ProvidingService",
+ "org.openecomp.resource.vfc": "VServerWidget",
+ "org.openecomp.resource.cp": "LIntfWidget",
+ "org.openecomp.cp": "LIntfWidget",
+ "org.openecomp.resource.vl": "L3Network",
+ "org.openecomp.resource.vf": "VirtualFunction",
+ "org.openecomp.groups.vfmodule": "VfModule",
+ "org.openecomp.groups.VfModule": "VfModule",
+ "org.openecomp.resource.vfc.nodes.heat.cinder": "VolumeWidget",
+ "org.openecomp.nodes.PortMirroringConfiguration": "Configuration",
+ "org.openecomp.resource.cr.Kk1806Cr1": "CR"
+ }
+}