summaryrefslogtreecommitdiffstats
path: root/openecomp-be
diff options
context:
space:
mode:
authorshiria <shiri.amichai@amdocs.com>2019-03-18 12:07:12 +0200
committerAvi Gaffa <avi.gaffa@amdocs.com>2019-03-18 12:15:08 +0000
commit20679b258fc6bfbcf3afa1f5aec6a94715f3ebf5 (patch)
tree6fa924ff808c87553d5434d9d7422962fc9f42c6 /openecomp-be
parent4192e3caac2662624a7368252a3bc5619539caa7 (diff)
Fix flat node type interface
Change-Id: I45457f1f33f2197c11d0711cedca82f53db5df79 Issue-ID: SDC-2198 Signed-off-by: shiria <shiri.amichai@amdocs.com>
Diffstat (limited to 'openecomp-be')
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java9
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java24
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/ServiceTemplateInterfaceInheritanceTest.yaml11
3 files changed, 41 insertions, 3 deletions
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java
index 1f0b728c53..332555d509 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java
@@ -920,10 +920,13 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
targetNodeType.setInterfaces(interfaceNoMerge.get());
return;
}
- targetNodeType.setInterfaces(combineInterfaces(sourceNodeType, targetNodeType));
+ combineInterfaces(sourceNodeType, targetNodeType).ifPresent(targetNodeType::setInterfaces);
}
- private Map<String, Object> combineInterfaces(NodeType sourceNodeType, NodeType targetNodeType) {
+ private Optional<Map<String, Object>> combineInterfaces(NodeType sourceNodeType, NodeType targetNodeType) {
+ if (MapUtils.isEmpty(sourceNodeType.getInterfaces())) {
+ return Optional.empty();
+ }
Map<String, Object> combineInterfaces = new HashMap<>();
for (Map.Entry<String, Object> sourceInterfaceDefEntry : sourceNodeType.getInterfaces().entrySet()) {
String interfaceName = sourceInterfaceDefEntry.getKey();
@@ -943,7 +946,7 @@ public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService {
}
}
- return combineInterfaces;
+ return Optional.of(combineInterfaces);
}
private Optional<Map<String, Object>> combineInterfaceNoMerge(NodeType sourceNodeType, NodeType targetNodeType) {
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java
index 4962f243ca..d2c1ed8a17 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java
@@ -85,6 +85,7 @@ public class ToscaAnalyzerServiceImplTest {
private static final String TOSCA_LIFECYCLE_STANDARD = "tosca.interfaces.node.lifecycle.Standard";
private static final String CMAUI_INTERFACE_TEST =
"org.openecomp.resource.vfc.nodes.heat.cmaui_image_interfaceTest";
+ private static final String NODE_TYPE_NO_INTERFACE = "org.openecomp.resource.vfc.nodes.nodeBNoInterface";
/*
Dictionary:
@@ -227,6 +228,29 @@ public class ToscaAnalyzerServiceImplTest {
}
}
+ @Test
+ public void testGetFlatNodeTypeNoInterfaces() throws Exception {
+ ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
+ try (InputStream yamlFile = toscaExtensionYamlUtil.loadYamlFileIs(
+ "/mock/analyzerService/ServiceTemplateInterfaceInheritanceTest.yaml")) {
+
+ ServiceTemplate serviceTemplateFromYaml =
+ toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
+
+ ToscaFlatData flatData = toscaAnalyzerService
+ .getFlatEntity(ToscaElementTypes.NODE_TYPE, NODE_TYPE_NO_INTERFACE,
+ serviceTemplateFromYaml, toscaServiceModel);
+
+ Assert.assertNotNull(flatData);
+ Assert.assertNotNull(flatData.getFlatEntity());
+ NodeType flatEntity = (NodeType) flatData.getFlatEntity();
+ Assert.assertNull(flatEntity.getInterfaces());
+ List<String> inheritanceHierarchyType = flatData.getInheritanceHierarchyType();
+ Assert.assertNotNull(inheritanceHierarchyType);
+ Assert.assertEquals(2, inheritanceHierarchyType.size());
+ }
+ }
+
@Test
public void testGetFlatEntityDataType() throws Exception {
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/ServiceTemplateInterfaceInheritanceTest.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/ServiceTemplateInterfaceInheritanceTest.yaml
index 17cfe33592..3df6798b6c 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/ServiceTemplateInterfaceInheritanceTest.yaml
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/ServiceTemplateInterfaceInheritanceTest.yaml
@@ -70,6 +70,17 @@ node_types:
name:
type: string
+ org.openecomp.resource.vfc.nodes.nodeANoInterface:
+ properties:
+ name:
+ type: string
+
+ org.openecomp.resource.vfc.nodes.nodeBNoInterface:
+ derived_from: org.openecomp.resource.vfc.nodes.nodeANoInterface
+ properties:
+ name:
+ type: string
+
data_types:
org.openecomp.datatypes.heat.network.MyAddressPair:
derived_from: org.openecomp.datatypes.heat.network.AddressPair