X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Forg%2Fonap%2Faai%2Fbabel%2Fparser%2FTestArtifactGeneratorToscaParser.java;h=50812c9450625484567d5c3c087de73f45fea690;hb=bfde3ef00beb3c6f31cebfd12e90b9b9cdcc492e;hp=50f0aa97e2fa0a80666a6be7091e1063c889dfaf;hpb=895cafe7aaf5f462e0bf3c3a2ab7fcb863bba78e;p=aai%2Fbabel.git 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 50f0aa9..50812c9 100644 --- a/src/test/java/org/onap/aai/babel/parser/TestArtifactGeneratorToscaParser.java +++ b/src/test/java/org/onap/aai/babel/parser/TestArtifactGeneratorToscaParser.java @@ -37,8 +37,11 @@ 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.Model; import org.onap.aai.babel.xml.generator.model.Resource; +import org.onap.aai.babel.xml.generator.model.Service; import org.onap.aai.babel.xml.generator.model.WidgetType; +import org.onap.aai.babel.xml.generator.types.ModelType; import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; import org.onap.sdc.toscaparser.api.Group; import org.onap.sdc.toscaparser.api.NodeTemplate; @@ -53,21 +56,9 @@ public class TestArtifactGeneratorToscaParser { private static final String TEST_UUID = "1234"; - /** - * Initialize the Generator with an invalid artifact generator properties file path. - * - * @throws IOException - * if an error occurs reading the configuration properties - */ - @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 * if the file content could not be read successfully */ @@ -78,7 +69,7 @@ public class TestArtifactGeneratorToscaParser { /** * Initialize the Generator with no Widget Mappings content. - * + * * @throws IOException * if the file content could not be read successfully */ @@ -90,7 +81,7 @@ public class TestArtifactGeneratorToscaParser { /** * Initialize the Generator with invalid Widget Mappings content. - * + * * @throws IOException * if the file content could not be read successfully */ @@ -123,7 +114,7 @@ public class TestArtifactGeneratorToscaParser { /** * Initialize the Artifact Generator Widget Mapping config with incomplete data (no type). - * + * * @throws IOException * if a WidgetMapping is invalid */ @@ -136,7 +127,7 @@ public class TestArtifactGeneratorToscaParser { /** * Initialize the Artifact Generator Widget Mapping config with invalid data (type value). - * + * * @throws IOException * if a WidgetMapping is invalid */ @@ -149,7 +140,7 @@ public class TestArtifactGeneratorToscaParser { /** * Initialize the Artifact Generator Widget Mapping config with incomplete data (no widget name). - * + * * @throws IOException * if a WidgetMapping is invalid */ @@ -160,9 +151,32 @@ public class TestArtifactGeneratorToscaParser { WidgetConfigurationUtil.setWidgetMappings(Collections.singletonList(invalidMapping)); } + /** + * Create a Resource with a Widget model type and add this to a Service. Note that there are no test CSAR files + * which require this functionality, but the code path exists to support it. + * + * @throws IOException + * if the widget mappings are not loaded + * @throws XmlArtifactGenerationException + * if there is no configuration defined for the test resource's widget type + */ + @Test + public void testAddWidgetToService() throws IOException, XmlArtifactGenerationException { + ArtifactTestUtils testUtils = new ArtifactTestUtils(); + testUtils.loadWidgetMappings(); + + Model serviceModel = new Service(); + Resource resourceModel = new Resource(WidgetType.valueOf("VF"), false); + resourceModel.setModelType(ModelType.WIDGET); + + ISdcCsarHelper helper = Mockito.mock(ISdcCsarHelper.class); + ArtifactGeneratorToscaParser parser = new ArtifactGeneratorToscaParser(helper); + parser.addRelatedModel(serviceModel, resourceModel); + } + /** * Process a dummy Group object for a Service Resource. - * + * * @throws XmlArtifactGenerationException * if there is no configuration defined for a member Widget of an instance group * @throws IOException