From d74d87cd27afca784a8ed582b6b7015a8a8d243a Mon Sep 17 00:00:00 2001 From: shiria Date: Tue, 1 May 2018 14:09:41 +0300 Subject: Fix TOSCA Analyzer - null point exception In case there is import to not exist TOSCA file, exception with relevant error message should be thrown In getRequirementAssignment, when there is no Requirement, Optional.Empty is returned Change-Id: I8aabde177815dec2f69307f6be3c5114c5c8efa3 Issue-ID: SDC-1281 Signed-off-by: shiria --- .../services/impl/ToscaAnalyzerServiceImplTest.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp') 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 83ed525c4c..e034fb8565 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 @@ -126,6 +126,26 @@ public class ToscaAnalyzerServiceImplTest { } } + @Test + public void testGetFlatEntityFileNotFound() throws Exception { + thrown.expect(CoreException.class); + thrown.expectMessage( + "Tosca file 'missingFile.yaml' was not found in tosca service model"); + ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil(); + try (InputStream yamlFile = toscaExtensionYamlUtil + .loadYamlFileIs("/mock/analyzerService/ServiceTemplateFileNotFoundTest.yaml")) { + + ServiceTemplate + serviceTemplateFromYaml = + toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class); + + toscaAnalyzerService + .getFlatEntity(ToscaElementTypes.NODE_TYPE, + "org.openecomp.resource.vfc.nodes.heat.cmaui_image", + serviceTemplateFromYaml, toscaServiceModel); + } + } + @Test public void testGetFlatEntityNodeType() throws Exception { ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil(); -- cgit 1.2.3-korg