From 5f3a0ea3230fc09bb66a5b6fbd65868fe2a46e6c Mon Sep 17 00:00:00 2001 From: vempo Date: Mon, 23 Oct 2017 13:28:46 +0300 Subject: Fixed resources not being released, code cleanup Properly close input streams; code cleanup; fixed static analysis violations and coding convetions. Change-Id: I53dabcc9f8898a0ab25636735cb0b5f84b57c427 Issue-ID: SDC-291 Signed-off-by: vempo --- .../core/converter/impl/ToscaConverterImplTest.java | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'openecomp-be/lib/openecomp-tosca-converter-lib') diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java index f29ca4a427..471e3891c7 100644 --- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java +++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/converter/impl/ToscaConverterImplTest.java @@ -41,22 +41,18 @@ public class ToscaConverterImplTest { private static final String VIRTUAL_LINK = "virtualLink"; private static final String UNBOUNDED = "UNBOUNDED"; - private static String inputFilesPath; - private static String outputFilesPath; - private static Map expectedOutserviceTemplates; - @Test public void testConvertMainSt() throws IOException { - inputFilesPath = "/mock/toscaConverter/convertMainSt/in"; - outputFilesPath = "/mock/toscaConverter/convertMainSt/out"; + String inputFilesPath = "/mock/toscaConverter/convertMainSt/in"; + String outputFilesPath = "/mock/toscaConverter/convertMainSt/out"; FileContentHandler fileContentHandler = createFileContentHandlerFromInput(inputFilesPath); - expectedOutserviceTemplates = new HashMap<>(); + Map expectedOutserviceTemplates = new HashMap<>(); loadServiceTemplates(outputFilesPath, new ToscaExtensionYamlUtil(), - expectedOutserviceTemplates); + expectedOutserviceTemplates); ToscaServiceModel toscaServiceModel = toscaConverter.convert(fileContentHandler); ServiceTemplate mainSt = toscaServiceModel.getServiceTemplates().get(mainStName); @@ -201,18 +197,15 @@ public class ToscaConverterImplTest { private static void addServiceTemplateFiles(Map serviceTemplates, File[] files, - ToscaExtensionYamlUtil toscaExtensionYamlUtil) - throws IOException { + ToscaExtensionYamlUtil toscaExtensionYamlUtil) throws IOException { + for (File file : files) { + try (InputStream yamlFile = new FileInputStream(file)) { ServiceTemplate serviceTemplateFromYaml = toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class); createConcreteRequirementObjectsInServiceTemplate(serviceTemplateFromYaml, toscaExtensionYamlUtil); serviceTemplates.put(file.getName(), serviceTemplateFromYaml); - try { - yamlFile.close(); - } catch (IOException ignore) { - } } } } -- cgit 1.2.3-korg