diff options
Diffstat (limited to 'src/test')
11 files changed, 188 insertions, 133 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 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.ArrayList; 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 @@ public class TestArtifactGeneratorToscaParser { @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 @@ 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/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.equalTo; 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.api.AaiArtifactGenerator; 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 @@ public class TestToscaParser { } } - 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 @@ public class TestToscaParser { 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 @@ import org.xml.sax.SAXException; */ 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 @@ public class CsarToXmlConverterTest { @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 @@ public class CsarToXmlConverterTest { * 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 class CsarToXmlConverterTest { 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.Test; 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 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * */ @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:/babel-beans.xml" }) +@ContextConfiguration(locations = {"classpath:/babel-beans.xml"}) public class TestGenerateArtifactsServiceImpl { static { @@ -65,18 +65,14 @@ public class TestGenerateArtifactsServiceImpl { 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 @@ public class TestGenerateArtifactsServiceImpl { 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.hamcrest.CoreMatchers.nullValue; 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.Base64; 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 @@ public class ArtifactTestUtils { 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 @@ public class ArtifactTestUtils { * 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 @@ public class ArtifactTestUtils { 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.is; 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 @@ public class TestModel { } /** - * 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.CoreMatchers.notNullValue; 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 @@ public class TestVfModule { 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 @@ public class TestVfModule { /** * 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 @@ public class TestVfModule { /** * 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 @@ public class TestVfModule { /** * 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 @@ public class TestVfModule { /** * 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 @@ public class TestVfModule { /** * 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 @@ public class TestVfModule { * 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 @@ public class TestVfModule { /** * 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 @@ public class TestVfModule { /** * 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.is; 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 @@ public class TestWidget { /** * 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" + } +} |