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();
}
}
- return combineInterfaces;
+ return Optional.of(combineInterfaces);
}
private Optional<Map<String, Object>> combineInterfaceNoMerge(NodeType sourceNodeType, NodeType targetNodeType) {
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:
}
}
+ @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 {
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