summaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java67
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java7
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java20
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java16
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java72
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateArtifact.java33
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/YamlTemplateParsingHandlerTest.java80
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java17
8 files changed, 245 insertions, 67 deletions
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<String, Object> nodeTemplateJsonMap) {
+ if (nodeTemplateJsonMap.containsKey(ARTIFACTS.getElementName())) {
+ Map<String, Map<String, UploadArtifactInfo>> eitherArtifactsRes = createArtifactsModuleFromYaml(nodeTemplateJsonMap);
+ if (!eitherArtifactsRes.isEmpty()) {
+ nodeTemplateInfo.setArtifacts(eitherArtifactsRes);
+ }
+ }
+ }
+
private void setRequirements(UploadComponentInstanceInfo nodeTemplateInfo, Map<String, Object> nodeTemplateJsonMap) {
if (nodeTemplateJsonMap.containsKey(REQUIREMENTS.getElementName())) {
Map<String, List<UploadReqInfo>> regResponse = createReqModuleFromYaml(nodeTemplateJsonMap);
@@ -591,6 +601,63 @@ public class YamlTemplateParsingHandler {
}
@SuppressWarnings("unchecked")
+ private Map<String, Map<String, UploadArtifactInfo>> createArtifactsModuleFromYaml(Map<String, Object> nodeTemplateJsonMap) {
+ Map<String, Map<String, UploadArtifactInfo>> moduleArtifacts = new HashMap<>();
+ Either<List<Object>, ResultStatusEnum> ArtifactsListRes =
+ findFirstToscaListElement(nodeTemplateJsonMap, ARTIFACTS);
+ if (ArtifactsListRes.isLeft()) {
+ for (Object jsonArtifactObj : ArtifactsListRes.left().value()) {
+ String key = ((Map<String, Object>) jsonArtifactObj).keySet().iterator().next();
+ Object artifactJson = ((Map<String, Object>) jsonArtifactObj).get(key);
+ addModuleNodeTemplateArtifacts(moduleArtifacts, artifactJson, key);
+ }
+ } else {
+ Either<Map<String, Map<String, Object>>, ResultStatusEnum> ArtifactsMapRes =
+ findFirstToscaMapElement(nodeTemplateJsonMap, ARTIFACTS);
+ if (ArtifactsMapRes.isLeft()) {
+ for (Map.Entry<String, Map<String, Object>> entry : ArtifactsMapRes.left().value().entrySet()) {
+ String artifactName = entry.getKey();
+ Object artifactJson = entry.getValue();
+ addModuleNodeTemplateArtifacts(moduleArtifacts, artifactJson, artifactName);
+ }
+ }
+ }
+ return moduleArtifacts;
+ }
+
+ private void addModuleNodeTemplateArtifacts(Map<String, Map<String, UploadArtifactInfo>> 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<String, UploadArtifactInfo> 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<String, Object>) artifactObject);
+ }
+ return artifactTemplateInfo;
+ }
+
+ private void fillArtifact(UploadArtifactInfo artifactTemplateInfo, Map<String, Object> 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<String, List<UploadCapInfo>> createCapModuleFromYaml(Map<String, Object> nodeTemplateJsonMap) {
Map<String, List<UploadCapInfo>> moduleCap = new HashMap<>();
Either<List<Object>, ResultStatusEnum> capabilitiesListRes =
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<Either<ArtifactDefinition, Operation>, ResponseFormat> generateAndSaveToscaArtifact(ArtifactDefinition artifactDefinition, org.openecomp.sdc.be.model.Component component, User user, boolean isInCertificationRequest,
- boolean shouldLock, boolean inTransaction, boolean fetchTemplatesFromDB) {
+ public Either<Either<ArtifactDefinition, Operation>, ResponseFormat> generateAndSaveToscaArtifact(
+ ArtifactDefinition artifactDefinition, org.openecomp.sdc.be.model.Component component,
+ User user, boolean isInCertificationRequest, boolean shouldLock, boolean inTransaction,
+ boolean fetchTemplatesFromDB) {
Either<Either<ArtifactDefinition, Operation>, 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<String, Map<String, UploadArtifactInfo>> artifacts = uploadComponentInstanceInfo.getArtifacts();
+ Map<String, ToscaArtifactDataDefinition> toscaArtifacts = new HashMap<>();
+ Map<String, Map<String, UploadArtifactInfo>> arts = artifacts.entrySet().stream()
+ .filter(e -> e.getKey().contains(TypeUtils.ToscaTagNamesEnum.ARTIFACTS.getElementName()))
+ .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue()));
+ Map<String, UploadArtifactInfo> artifact = arts.get(TypeUtils.ToscaTagNamesEnum.ARTIFACTS.getElementName());
+ for (Map.Entry<String, UploadArtifactInfo> 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<String, ToscaGroupTemplate> 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<String, ToscaTemplateArtifact> convertToNodeTemplateArtifacts(Map<String, ToscaArtifactDataDefinition> artifacts) {
+ if (artifacts == null) {
+ return null;
+ }
+ Map<String, ToscaTemplateArtifact> arts = new HashMap<>();
+ for (Map.Entry<String, ToscaArtifactDataDefinition> 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<String, Object> properties;
private List<Map<String, ToscaTemplateRequirement>> requirements;
private Map<String, ToscaTemplateCapability> capabilities;
+ private Map<String, ToscaTemplateArtifact> artifacts;
private NodeFilter node_filter;
private Map<String, Object> interfaces;
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public Map<String, Object> getProperties() {
- return properties;
- }
-
- public void setProperties(Map<String, Object> properties) {
- this.properties = properties;
- }
-
- public List<Map<String, ToscaTemplateRequirement>> getRequirements() {
- return requirements;
- }
-
- public void setRequirements(List<Map<String, ToscaTemplateRequirement>> requirements) {
- this.requirements = requirements;
- }
-
- public Map<String, ToscaTemplateCapability> getCapabilities() {
- return capabilities;
- }
-
- public void setCapabilities(Map<String, ToscaTemplateCapability> 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<String> getDirectives() {
- return directives;
- }
-
public void setDirectives(List<String> 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<String, Object> 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<String, Object> nodeTemplateJsonMap = new HashMap<>();
+ Map<String, String> 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<String, Map<String, Map<String, String>>> nodeTemplateJsonMap = new HashMap<>();
+ Map<String, Map<String,String>> map0 = new HashMap<>();
+ Map<String, String> map1 = new HashMap<>();
+ map1.put("file", "test_file");
+ map1.put("type", "test_type");
+ map0.put("test_art", map1);
+ nodeTemplateJsonMap.put(ARTIFACTS.getElementName(), map0);
+ Map<String, Map<String, UploadArtifactInfo>> 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<String, Map<String, UploadArtifactInfo>> result = new HashMap<>();
+ Map<String, String> 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<String, String> 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<String, String> 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<String, ToscaArtifactDataDefinition> container = new HashMap<>();
+ ToscaArtifactDataDefinition art = new ToscaArtifactDataDefinition();
+ art.setFile("test_file");
+ art.setType("test_type");
+ Map<String, ToscaTemplateArtifact> 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"));
+ }
}