summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-translator-lib/att-sdc-translator-impl
diff options
context:
space:
mode:
authorvempo <vitaliy.emporopulo@amdocs.com>2017-09-07 10:52:29 +0300
committerVitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com>2017-09-07 13:53:33 +0000
commitb7375b2488df93ba9df57ad13ec628bbff663819 (patch)
treee8d372535ab98aa76814e16d301ac32efbeb0c75 /openecomp-be/lib/openecomp-sdc-translator-lib/att-sdc-translator-impl
parent8bd8cee7d620406036e197f540439b1e226506d5 (diff)
Fixed a few static analysis violations
Fixed mostly not closing resources (InputStream, ResultSet) and catching Throwable instead of Exception in some modules. Issue-ID: SDC-291 Change-Id: I34e331cc3b45c4bb3a71c301f50e1706a7b623fd Signed-off-by: vempo <vitaliy.emporopulo@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-translator-lib/att-sdc-translator-impl')
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/att-sdc-translator-impl/src/test/java/com/att/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceTranslationTest.java19
1 files changed, 8 insertions, 11 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/att-sdc-translator-impl/src/test/java/com/att/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceTranslationTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/att-sdc-translator-impl/src/test/java/com/att/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceTranslationTest.java
index cac3c4ce08..e8fddc3108 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/att-sdc-translator-impl/src/test/java/com/att/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceTranslationTest.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/att-sdc-translator-impl/src/test/java/com/att/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceTranslationTest.java
@@ -20,16 +20,12 @@
package com.att.sdc.translator.services.heattotosca.impl.resourcetranslation;
-import static org.junit.Assert.assertEquals;
-
import org.apache.commons.collections4.MapUtils;
import org.junit.Assert;
import org.junit.Before;
import org.openecomp.core.translator.datatypes.TranslatorOutput;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.utilities.json.JsonUtil;
-import org.openecomp.core.validation.api.ValidationManager;
-import org.openecomp.core.validation.factory.ValidationManagerFactory;
import org.openecomp.core.validation.util.MessageContainerUtil;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCategory;
@@ -46,9 +42,9 @@ import org.openecomp.sdc.logging.types.LoggerErrorCode;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import org.openecomp.sdc.tosca.datatypes.model.GroupDefinition;
import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.sdc.tosca.services.ToscaExtensionYamlUtil;
import org.openecomp.sdc.tosca.services.ToscaFileOutputService;
import org.openecomp.sdc.tosca.services.impl.ToscaFileOutputServiceCsarImpl;
-import org.openecomp.sdc.tosca.services.ToscaExtensionYamlUtil;
import org.openecomp.sdc.translator.datatypes.heattotosca.TranslationContext;
import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ComputeTemplateConsolidationData;
import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ConsolidationData;
@@ -61,7 +57,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.HashSet;
@@ -71,6 +66,8 @@ import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
+import static org.junit.Assert.assertEquals;
+
public class BaseResourceTranslationTest {
@@ -280,14 +277,14 @@ public class BaseResourceTranslationTest {
} else {
Assert.fail("Invalid expected output files directory");
}
+
for (int i = 0; i < fileList.length; i++) {
- InputStream serviceTemplateInputStream = FileUtils.getFileInputStream
- (BaseResourceTranslationTest.class
- .getClassLoader().getResource(baseDirPath + fileList[i]));
- ServiceTemplate serviceTemplate = toscaExtensionYamlUtil.yamlToObject
- (serviceTemplateInputStream, ServiceTemplate.class);
+ URL resource = BaseResourceTranslationTest.class.getClassLoader().getResource(baseDirPath + fileList[i]);
+ ServiceTemplate serviceTemplate = FileUtils.readViaInputStream(resource,
+ stream -> toscaExtensionYamlUtil.yamlToObject(stream, ServiceTemplate.class));
serviceTemplateMap.put(fileList[i], serviceTemplate);
}
+
} catch (Exception e) {
Assert.fail(e.getMessage());
}