From 8ff60789e080dd99c604d31a6e754be164fba11e Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Mon, 15 Apr 2019 00:05:05 -0700 Subject: add artifacts support in TOSCA exported yml file Change-Id: I56f8a6a1ce758876e83a7ee8318b79644ae7d5cb Issue-ID: SDC-1952 Signed-off-by: Liang Ding --- .../csar/YamlTemplateParsingHandler.java | 67 ++++++++++++++++++ .../be/components/impl/ArtifactsBusinessLogic.java | 7 +- .../be/components/impl/ResourceBusinessLogic.java | 20 ++++++ .../openecomp/sdc/be/tosca/ToscaExportHandler.java | 16 +++++ .../sdc/be/tosca/model/ToscaNodeTemplate.java | 72 ++----------------- .../sdc/be/tosca/model/ToscaTemplateArtifact.java | 33 +++++++++ .../impl/utils/YamlTemplateParsingHandlerTest.java | 80 ++++++++++++++++++++++ .../sdc/be/tosca/ToscaExportHandlerTest.java | 17 +++++ 8 files changed, 245 insertions(+), 67 deletions(-) create mode 100644 catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateArtifact.java (limited to 'catalog-be/src') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java index 7b3d4fac25..cff6c26e58 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java @@ -467,6 +467,7 @@ public class YamlTemplateParsingHandler { setToscaResourceType(createdNodesToscaResourceNames, nodeTemplateInfo, nodeTemplateJsonMap); setRequirements(nodeTemplateInfo, nodeTemplateJsonMap); setCapabilities(nodeTemplateInfo, nodeTemplateJsonMap); + setArtifacts(nodeTemplateInfo, nodeTemplateJsonMap); updateProperties(nodeTemplateInfo, nodeTemplateJsonMap); setDirectives(nodeTemplateInfo, nodeTemplateJsonMap); setNodeFilter(nodeTemplateInfo, nodeTemplateJsonMap); @@ -515,6 +516,15 @@ public class YamlTemplateParsingHandler { } } + private void setArtifacts(UploadComponentInstanceInfo nodeTemplateInfo, Map nodeTemplateJsonMap) { + if (nodeTemplateJsonMap.containsKey(ARTIFACTS.getElementName())) { + Map> eitherArtifactsRes = createArtifactsModuleFromYaml(nodeTemplateJsonMap); + if (!eitherArtifactsRes.isEmpty()) { + nodeTemplateInfo.setArtifacts(eitherArtifactsRes); + } + } + } + private void setRequirements(UploadComponentInstanceInfo nodeTemplateInfo, Map nodeTemplateJsonMap) { if (nodeTemplateJsonMap.containsKey(REQUIREMENTS.getElementName())) { Map> regResponse = createReqModuleFromYaml(nodeTemplateJsonMap); @@ -590,6 +600,63 @@ public class YamlTemplateParsingHandler { } } + @SuppressWarnings("unchecked") + private Map> createArtifactsModuleFromYaml(Map nodeTemplateJsonMap) { + Map> moduleArtifacts = new HashMap<>(); + Either, ResultStatusEnum> ArtifactsListRes = + findFirstToscaListElement(nodeTemplateJsonMap, ARTIFACTS); + if (ArtifactsListRes.isLeft()) { + for (Object jsonArtifactObj : ArtifactsListRes.left().value()) { + String key = ((Map) jsonArtifactObj).keySet().iterator().next(); + Object artifactJson = ((Map) jsonArtifactObj).get(key); + addModuleNodeTemplateArtifacts(moduleArtifacts, artifactJson, key); + } + } else { + Either>, ResultStatusEnum> ArtifactsMapRes = + findFirstToscaMapElement(nodeTemplateJsonMap, ARTIFACTS); + if (ArtifactsMapRes.isLeft()) { + for (Map.Entry> entry : ArtifactsMapRes.left().value().entrySet()) { + String artifactName = entry.getKey(); + Object artifactJson = entry.getValue(); + addModuleNodeTemplateArtifacts(moduleArtifacts, artifactJson, artifactName); + } + } + } + return moduleArtifacts; + } + + private void addModuleNodeTemplateArtifacts(Map> moduleArtifacts, Object artifactJson, String artifactName) { + + UploadArtifactInfo artifact = buildModuleNodeTemplateArtifact(artifactJson); + artifact.setName(artifactName); + if (moduleArtifacts.containsKey(ARTIFACTS.getElementName())) { + moduleArtifacts.get(ARTIFACTS.getElementName()).put(artifactName, artifact); + } else { + Map map = new HashMap<>(); + map.put(artifactName, artifact); + moduleArtifacts.put(ARTIFACTS.getElementName(), map); + } + } + + @SuppressWarnings("unchecked") + private UploadArtifactInfo buildModuleNodeTemplateArtifact(Object artifactObject) { + UploadArtifactInfo artifactTemplateInfo = new UploadArtifactInfo(); + if (artifactObject instanceof Map) { + fillArtifact(artifactTemplateInfo, (Map) artifactObject); + } + return artifactTemplateInfo; + } + + private void fillArtifact(UploadArtifactInfo artifactTemplateInfo, Map nodeTemplateJsonMap) { + if (nodeTemplateJsonMap.containsKey(TYPE.getElementName())) { + artifactTemplateInfo.setType((String) nodeTemplateJsonMap.get(TYPE.getElementName())); + } + if (nodeTemplateJsonMap.containsKey(FILE.getElementName())) { + artifactTemplateInfo.setFile((String) nodeTemplateJsonMap.get(FILE.getElementName())); + } + } + + @SuppressWarnings("unchecked") private Map> createCapModuleFromYaml(Map nodeTemplateJsonMap) { Map> moduleCap = new HashMap<>(); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java index 3d149f79e6..9eae363afb 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java @@ -52,6 +52,7 @@ import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition; import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition; import org.openecomp.sdc.be.datatypes.elements.GroupInstanceDataDefinition; import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.ToscaArtifactDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; @@ -388,8 +389,10 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { .equals(ArtifactTypeEnum.TOSCA_CSAR.getType()) && StringUtils.isEmpty(artifactInfo.getArtifactChecksum()); } - public Either, ResponseFormat> generateAndSaveToscaArtifact(ArtifactDefinition artifactDefinition, org.openecomp.sdc.be.model.Component component, User user, boolean isInCertificationRequest, - boolean shouldLock, boolean inTransaction, boolean fetchTemplatesFromDB) { + public Either, ResponseFormat> generateAndSaveToscaArtifact( + ArtifactDefinition artifactDefinition, org.openecomp.sdc.be.model.Component component, + User user, boolean isInCertificationRequest, boolean shouldLock, boolean inTransaction, + boolean fetchTemplatesFromDB) { Either, ResponseFormat> generated = generateToscaArtifact(component, artifactDefinition, isInCertificationRequest, fetchTemplatesFromDB); if (generated.isRight()) { diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java index 5a997205ea..12345e7802 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java @@ -47,6 +47,7 @@ import java.util.Optional; import java.util.Set; import java.util.function.Function; import java.util.regex.Pattern; +import java.util.stream.Collectors; import fj.data.Either; import org.apache.commons.codec.binary.Base64; @@ -83,6 +84,7 @@ import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition; import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition; import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.datatypes.elements.RequirementDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.ToscaArtifactDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentFieldsEnum; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.CreatedFrom; @@ -115,6 +117,7 @@ import org.openecomp.sdc.be.model.RelationshipInfo; import org.openecomp.sdc.be.model.RequirementCapabilityRelDef; import org.openecomp.sdc.be.model.RequirementDefinition; import org.openecomp.sdc.be.model.Resource; +import org.openecomp.sdc.be.model.UploadArtifactInfo; import org.openecomp.sdc.be.model.UploadCapInfo; import org.openecomp.sdc.be.model.UploadComponentInstanceInfo; import org.openecomp.sdc.be.model.UploadInfo; @@ -3113,6 +3116,23 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { uploadComponentInstanceInfo.getCapabilities()); componentInstance.setCapabilities(validComponentInstanceCapabilities); } + + if (isNotEmpty(uploadComponentInstanceInfo.getArtifacts())) { + Map> artifacts = uploadComponentInstanceInfo.getArtifacts(); + Map toscaArtifacts = new HashMap<>(); + Map> arts = artifacts.entrySet().stream() + .filter(e -> e.getKey().contains(TypeUtils.ToscaTagNamesEnum.ARTIFACTS.getElementName())) + .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue())); + Map artifact = arts.get(TypeUtils.ToscaTagNamesEnum.ARTIFACTS.getElementName()); + for (Map.Entry entry : artifact.entrySet()) { + ToscaArtifactDataDefinition to = new ToscaArtifactDataDefinition(); + to.setFile(entry.getValue().getFile()); + to.setType(entry.getValue().getType()); + toscaArtifacts.put(entry.getKey(), to); + } + componentInstance.setToscaArtifacts(toscaArtifacts); + } + if (!existingnodeTypeMap.containsKey(uploadComponentInstanceInfo.getType())) { log.debug( "createResourceInstances - not found lates version for resource instance with name {} and type ", diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java index 0d3836b1c9..257ea3675d 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java @@ -658,6 +658,9 @@ public class ToscaExportHandler { Map groupsMap = null; for (ComponentInstance componentInstance : componentInstances) { ToscaNodeTemplate nodeTemplate = new ToscaNodeTemplate(); + if (MapUtils.isNotEmpty(componentInstance.getToscaArtifacts())) { + nodeTemplate.setArtifacts(convertToNodeTemplateArtifacts(componentInstance.getToscaArtifacts())); + } nodeTemplate.setType(componentInstance.getToscaComponentName()); nodeTemplate.setDirectives(componentInstance.getDirectives()); nodeTemplate.setNode_filter(convertToNodeTemplateNodeFilterComponent(componentInstance.getNodeFilter())); @@ -1249,6 +1252,19 @@ public class ToscaExportHandler { return Either.left(nodeType); } + private Map convertToNodeTemplateArtifacts(Map artifacts) { + if (artifacts == null) { + return null; + } + Map arts = new HashMap<>(); + for (Map.Entry entry : artifacts.entrySet()) { + ToscaTemplateArtifact artifact = new ToscaTemplateArtifact(); + artifact.setFile(entry.getValue().getFile()); + artifact.setType(entry.getValue().getType()); + arts.put(entry.getKey(), artifact); + } + return arts; + } protected NodeFilter convertToNodeTemplateNodeFilterComponent(CINodeFilterDataDefinition inNodeFilter) { if (inNodeFilter == null){ diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java index b17dc3a43f..d757cec36c 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java @@ -27,6 +27,11 @@ import java.util.List; import java.util.Map; import org.apache.commons.collections.CollectionUtils; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter public class ToscaNodeTemplate { private String type; @@ -36,61 +41,10 @@ public class ToscaNodeTemplate { private Map properties; private List> requirements; private Map capabilities; + private Map artifacts; private NodeFilter node_filter; private Map interfaces; - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public Map getProperties() { - return properties; - } - - public void setProperties(Map properties) { - this.properties = properties; - } - - public List> getRequirements() { - return requirements; - } - - public void setRequirements(List> requirements) { - this.requirements = requirements; - } - - public Map getCapabilities() { - return capabilities; - } - - public void setCapabilities(Map capabilities) { - this.capabilities = capabilities; - } - - public ToscaMetadata getMetadata() { - return metadata; - } - - public void setMetadata(ToscaMetadata metadata) { - this.metadata = metadata; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public List getDirectives() { - return directives; - } - public void setDirectives(List directives) { if (CollectionUtils.isEmpty(directives)) { this.directives = null; @@ -99,19 +53,6 @@ public class ToscaNodeTemplate { this.directives = directives; } - public NodeFilter getNode_filter() { - return node_filter; - } - - public void setNode_filter(NodeFilter node_filter) { - this.node_filter = node_filter; - } - - public void setInterfaces( - Map interfaces) { - this.interfaces = interfaces; - } - public void addInterface(String interfaceName, Object interfaceDataDefinition) { if (MapUtils.isEmpty(this.interfaces)) { this.interfaces = new HashMap<>(); @@ -120,3 +61,4 @@ public class ToscaNodeTemplate { this.interfaces.put(interfaceName, interfaceDataDefinition); } } + diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateArtifact.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateArtifact.java new file mode 100644 index 0000000000..58432ba29b --- /dev/null +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateArtifact.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.openecomp.sdc.be.tosca.model; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class ToscaTemplateArtifact { + + private String file; + private String type; + +} diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/YamlTemplateParsingHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/YamlTemplateParsingHandlerTest.java index 347c95217d..19d1a17e84 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/YamlTemplateParsingHandlerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/YamlTemplateParsingHandlerTest.java @@ -20,6 +20,8 @@ package org.openecomp.sdc.be.components.impl.utils; +import mockit.Deencapsulation; +import org.apache.commons.collections.MapUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertNotNull; import static org.mockito.ArgumentMatchers.eq; @@ -31,10 +33,12 @@ import java.util.*; import java.util.stream.Collectors; import org.assertj.core.util.Lists; +import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; @@ -49,6 +53,14 @@ import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.model.*; import org.openecomp.sdc.be.model.operations.impl.AnnotationTypeOperations; +import java.io.File; +import java.io.IOException; +import java.io.StringReader; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.*; @RunWith(MockitoJUnitRunner.class) public class YamlTemplateParsingHandlerTest { @@ -87,6 +99,9 @@ public class YamlTemplateParsingHandlerTest { private static final String MAIN_GROUP_NAME = "x_group"; private static final String NESTED_GROUP_NAME = "nested_mg_vepdg_group"; + @InjectMocks + YamlTemplateParsingHandler testSubject; + @BeforeClass() public static void prepareData() throws IOException, URISyntaxException { csar = ZipUtil.readData(CSAR_FILE_PATH); @@ -249,4 +264,69 @@ public class YamlTemplateParsingHandlerTest { return property; } + @Test + public void testSetArtifacts() throws Exception { + UploadComponentInstanceInfo nodeTemplateInfo = new UploadComponentInstanceInfo(); + Map nodeTemplateJsonMap = new HashMap<>(); + Map nodeMap = new HashMap<>(); + nodeMap.put("name","test_name"); + nodeMap.put("type","test_type"); + nodeTemplateJsonMap.put(ARTIFACTS.getElementName(), nodeMap); + Deencapsulation.invoke(testSubject, "setArtifacts", nodeTemplateInfo, nodeTemplateJsonMap); + Assert.assertTrue(nodeTemplateInfo.getArtifacts() != null); + } + + @Test + public void testCreateArtifactsModuleFromYaml() throws Exception { + Map>> nodeTemplateJsonMap = new HashMap<>(); + Map> map0 = new HashMap<>(); + Map map1 = new HashMap<>(); + map1.put("file", "test_file"); + map1.put("type", "test_type"); + map0.put("test_art", map1); + nodeTemplateJsonMap.put(ARTIFACTS.getElementName(), map0); + Map> result; + result = Deencapsulation.invoke(testSubject, "createArtifactsModuleFromYaml", nodeTemplateJsonMap); + Assert.assertTrue(MapUtils.isNotEmpty(result)); + Assert.assertTrue(MapUtils.isNotEmpty(result.get(ARTIFACTS.getElementName()))); + Assert.assertTrue(result.get(ARTIFACTS.getElementName()).get("test_art").getFile().equals("test_file")); + Assert.assertTrue(result.get(ARTIFACTS.getElementName()).get("test_art").getType().equals("test_type")); + } + + @Test + public void testAddModuleNodeTemplateArtifacts() throws Exception { + Map> result = new HashMap<>(); + Map map1 = new HashMap<>(); + map1.put("file", "test_file"); + map1.put("type", "test_type"); + Deencapsulation.invoke(testSubject, "addModuleNodeTemplateArtifacts", result, map1, "test_art"); + Assert.assertTrue(MapUtils.isNotEmpty(result)); + Assert.assertTrue(MapUtils.isNotEmpty(result.get(ARTIFACTS.getElementName()))); + Assert.assertTrue(result.get(ARTIFACTS.getElementName()).get("test_art").getFile().equals("test_file")); + Assert.assertTrue(result.get(ARTIFACTS.getElementName()).get("test_art").getType().equals("test_type")); + } + + @Test + public void testBuildModuleNodeTemplateArtifact() throws Exception { + Map map1 = new HashMap<>(); + map1.put("file", "test_file"); + map1.put("type", "test_type"); + UploadArtifactInfo result; + result = Deencapsulation.invoke(testSubject, "buildModuleNodeTemplateArtifact", map1); + Assert.assertTrue(result != null); + Assert.assertTrue(result.getFile().equals("test_file")); + Assert.assertTrue(result.getType().equals("test_type")); + } + + @Test + public void testFillArtifact() throws Exception { + Map map1 = new HashMap<>(); + map1.put("file", "test_file"); + map1.put("type", "test_type"); + UploadArtifactInfo result = new UploadArtifactInfo(); + Deencapsulation.invoke(testSubject, "fillArtifact", result, map1); + Assert.assertTrue(result != null); + Assert.assertTrue(result.getFile().equals("test_file")); + Assert.assertTrue(result.getType().equals("test_type")); + } } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java index f319643fd6..5521f8683b 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java @@ -29,6 +29,7 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; import mockit.Deencapsulation; +import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Triple; import org.junit.Assert; @@ -47,6 +48,7 @@ import org.openecomp.sdc.be.datatypes.elements.ForwardingPathElementDataDefiniti import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition; import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.datatypes.elements.RequirementDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.ToscaArtifactDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum; import org.openecomp.sdc.be.model.ArtifactDefinition; @@ -81,6 +83,7 @@ import org.openecomp.sdc.be.tosca.model.ToscaNodeTemplate; import org.openecomp.sdc.be.tosca.model.ToscaNodeType; import org.openecomp.sdc.be.tosca.model.ToscaProperty; import org.openecomp.sdc.be.tosca.model.ToscaTemplate; +import org.openecomp.sdc.be.tosca.model.ToscaTemplateArtifact; import org.openecomp.sdc.be.tosca.model.ToscaTemplateRequirement; import org.openecomp.sdc.be.tosca.model.ToscaTopolgyTemplate; import org.openecomp.sdc.be.tosca.utils.InputConverter; @@ -1349,4 +1352,18 @@ public class ToscaExportHandlerTest extends BeConfDependentTest { // default test result = Deencapsulation.invoke(testSubject, "convertCapabilities", component, nodeType, dataTypes); } + + @Test + public void testConvertToNodeTemplateArtifacts() throws Exception { + Map container = new HashMap<>(); + ToscaArtifactDataDefinition art = new ToscaArtifactDataDefinition(); + art.setFile("test_file"); + art.setType("test_type"); + Map result; + container.put("test_art", art); + result = Deencapsulation.invoke(testSubject, "convertToNodeTemplateArtifacts", container); + Assert.assertTrue(MapUtils.isNotEmpty(result)); + Assert.assertTrue(result.get("test_art").getFile().equals("test_file")); + Assert.assertTrue(result.get("test_art").getType().equals("test_type")); + } } -- cgit 1.2.3-korg