summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/openecomp-common-configuration-management/openecomp-configuration-management-core/src/main/java/org/openecomp/config/ConfigurationUtils.java11
-rw-r--r--common/openecomp-logging-lib/openecomp-logging-api/src/main/java/org/openecomp/core/logging/api/LoggerFactory.java4
-rw-r--r--common/openecomp-logging-lib/openecomp-logging-api/src/main/java/org/openecomp/core/logging/api/context/TaskFactory.java4
-rw-r--r--common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-test/src/main/java/org/openecomp/sdc/generator/ArtifactGenerationServiceTest.java8
-rw-r--r--common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-test/src/main/java/org/openecomp/sdc/generator/SampleJUnitTest.java424
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java18
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java16
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-core/src/main/java/org/openecomp/core/factory/FactoriesConfigImpl.java16
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-api/src/main/java/org/openecomp/core/util/UniqueValueUtil.java8
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/CassandraUtils.java7
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileUtils.java70
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/java/org/openecomp/core/utilities/json/JsonSchemaDataGeneratorTest.java23
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/java/org/openecomp/core/utilities/json/JsonUtilTest.java21
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java12
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ExternalArtifactEnricher.java8
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricherTest.java5
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricherTest.java6
-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
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/TestUtils.java9
19 files changed, 253 insertions, 436 deletions
diff --git a/common/openecomp-common-configuration-management/openecomp-configuration-management-core/src/main/java/org/openecomp/config/ConfigurationUtils.java b/common/openecomp-common-configuration-management/openecomp-configuration-management-core/src/main/java/org/openecomp/config/ConfigurationUtils.java
index c0a1e0ceb0..889efea3da 100644
--- a/common/openecomp-common-configuration-management/openecomp-configuration-management-core/src/main/java/org/openecomp/config/ConfigurationUtils.java
+++ b/common/openecomp-common-configuration-management/openecomp-configuration-management-core/src/main/java/org/openecomp/config/ConfigurationUtils.java
@@ -584,14 +584,19 @@ public class ConfigurationUtils {
stmt.setString(i + 1, params[i]);
}
}
- ResultSet rs = stmt.executeQuery();
- while (rs.next()) {
- coll.add(rs.getString(1));
+
+ try (ResultSet rs = stmt.executeQuery()) {
+
+ while (rs.next()) {
+ coll.add(rs.getString(1));
+ }
}
+
} catch (Exception exception) {
//exception.printStackTrace();
return null;
}
+
return coll;
}
diff --git a/common/openecomp-logging-lib/openecomp-logging-api/src/main/java/org/openecomp/core/logging/api/LoggerFactory.java b/common/openecomp-logging-lib/openecomp-logging-api/src/main/java/org/openecomp/core/logging/api/LoggerFactory.java
index e6f4aa3707..fdc874ee54 100644
--- a/common/openecomp-logging-lib/openecomp-logging-api/src/main/java/org/openecomp/core/logging/api/LoggerFactory.java
+++ b/common/openecomp-logging-lib/openecomp-logging-api/src/main/java/org/openecomp/core/logging/api/LoggerFactory.java
@@ -41,8 +41,8 @@ public class LoggerFactory extends BaseFactory {
try {
service = locateService(LoggerCreationService.class);
- } catch (Throwable throwable) {
- new RuntimeException("Failed to instantiate logger factory", throwable).printStackTrace();
+ } catch (Exception e) {
+ new RuntimeException("Failed to instantiate logger factory", e).printStackTrace();
// use the no-op service to prevent recursion in case of an attempt to log an exception as a
// result of a logger initialization error
service = new NoOpLoggerCreationService();
diff --git a/common/openecomp-logging-lib/openecomp-logging-api/src/main/java/org/openecomp/core/logging/api/context/TaskFactory.java b/common/openecomp-logging-lib/openecomp-logging-api/src/main/java/org/openecomp/core/logging/api/context/TaskFactory.java
index b358a77573..30bc7372c6 100644
--- a/common/openecomp-logging-lib/openecomp-logging-api/src/main/java/org/openecomp/core/logging/api/context/TaskFactory.java
+++ b/common/openecomp-logging-lib/openecomp-logging-api/src/main/java/org/openecomp/core/logging/api/context/TaskFactory.java
@@ -46,8 +46,8 @@ public class TaskFactory extends BaseFactory {
try {
service = locateService(ContextPropagationService.class);
- } catch (Throwable throwable) {
- error = new RuntimeException("Failed to instantiate task factory", throwable);
+ } catch (Exception e) {
+ error = new RuntimeException("Failed to instantiate task factory", e);
}
SERVICE = service;
diff --git a/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-test/src/main/java/org/openecomp/sdc/generator/ArtifactGenerationServiceTest.java b/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-test/src/main/java/org/openecomp/sdc/generator/ArtifactGenerationServiceTest.java
index 85479e31da..ced8acbb80 100644
--- a/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-test/src/main/java/org/openecomp/sdc/generator/ArtifactGenerationServiceTest.java
+++ b/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-test/src/main/java/org/openecomp/sdc/generator/ArtifactGenerationServiceTest.java
@@ -34,6 +34,7 @@ import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import java.io.ByteArrayInputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.Properties;
@@ -604,8 +605,11 @@ public class ArtifactGenerationServiceTest {
try {
jaxbContext = JAXBContext.newInstance(Model.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
- InputStream aaiModelStream = new ByteArrayInputStream(aaiModel.getBytes());
- return (Model) unmarshaller.unmarshal(aaiModelStream);
+
+ try (InputStream aaiModelStream = new ByteArrayInputStream(aaiModel.getBytes())) {
+ return (Model) unmarshaller.unmarshal(aaiModelStream);
+ } catch (IOException ignored) { /* ignore */ }
+
} catch (JAXBException e) {
e.printStackTrace();
}
diff --git a/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-test/src/main/java/org/openecomp/sdc/generator/SampleJUnitTest.java b/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-test/src/main/java/org/openecomp/sdc/generator/SampleJUnitTest.java
index bbbb74dc05..6d44a37a92 100644
--- a/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-test/src/main/java/org/openecomp/sdc/generator/SampleJUnitTest.java
+++ b/common/openecomp-sdc-artifact-generator-lib/openecomp-sdc-artifact-generator-test/src/main/java/org/openecomp/sdc/generator/SampleJUnitTest.java
@@ -67,7 +67,10 @@ public class SampleJUnitTest extends TestCase {
if (configLocation != null) {
File file = new File(configLocation);
if (file.exists()) {
- properties.load(new FileInputStream(file));
+
+ try (InputStream fis = new FileInputStream(file)) {
+ properties.load(fis);
+ }
}
}
}
@@ -86,12 +89,9 @@ public class SampleJUnitTest extends TestCase {
public void testArtifactGenerationSingleVFSingleVFModule() {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_SingleVFVFMod.yml");
- readPayload(inputArtifacts, fis1, "vf_vmme_template_SingleVFVFMod.yml");
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_SingleVFVFMod.yml");
- fis1.close();
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_SingleVFVFMod.yml");
- readPayload(inputArtifacts, fis2, "service_vmme_template_SingleVFVFMod.yml");
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_SingleVFVFMod.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -124,8 +124,7 @@ public class SampleJUnitTest extends TestCase {
public void testArtifactGenerationMissingVFInServiceTOSCA() {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_MissingVFInServiceTOSCA.yml");
- readPayload(inputArtifacts, fis2, "service_vmme_template_MissingVFInServiceTOSCA.yml");
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_MissingVFInServiceTOSCA.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -156,12 +155,9 @@ public class SampleJUnitTest extends TestCase {
public void testArtifactGenerationVerifySameStaticWidgetsForAllServices() {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_SameWidgets1.yml");
- readPayload(inputArtifacts, fis1, "vf_vmme_template_SameWidgets1.yml");
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_SameWidgets1.yml");
- fis1.close();
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_SameWidget1.yml");
- readPayload(inputArtifacts, fis2, "service_vmme_template_SameWidget1.yml");
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_SameWidget1.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -179,11 +175,9 @@ public class SampleJUnitTest extends TestCase {
List<Artifact> inputArtifacts2 = new ArrayList();
- InputStream fis3 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_SameWidgets2.yml");
- readPayload(inputArtifacts2, fis3, "vf_vmme_template_SameWidgets2.yml");
+ readPayloadFromResource(inputArtifacts2, "vf_vmme_template_SameWidgets2.yml");
- InputStream fis4 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_SameWidget2.yml");
- readPayload(inputArtifacts2, fis4, "service_vmme_template_SameWidget2.yml");
+ readPayloadFromResource(inputArtifacts2, "service_vmme_template_SameWidget2.yml");
ArtifactGenerationServiceImpl obj2 = new ArtifactGenerationServiceImpl();
GenerationData data2 = obj2.generateArtifact(inputArtifacts2, generatorConfig,additionalParams);
@@ -230,12 +224,9 @@ public class SampleJUnitTest extends TestCase {
try {
List<Artifact> inputArtifacts = new ArrayList();
String[] resourceFileList = {};
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_MulVFVFMod.yml");
- readPayload(inputArtifacts,fis1, "vf_vmme_template_MulVFVFMod.yml");
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_MulVFVFMod.yml");
- fis1.close();
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_MulVFVFMod.yml");
- readPayload(inputArtifacts,fis2, "service_vmme_template_MulVFVFMod.yml");
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_MulVFVFMod.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -268,17 +259,13 @@ public class SampleJUnitTest extends TestCase {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis3 = SampleJUnitTest.class.getResourceAsStream("/CMAUI_VF.yaml");
- readPayload(inputArtifacts,fis3, "CMAUI_VF.yaml");
+ readPayloadFromResource(inputArtifacts, "CMAUI_VF.yaml");
- InputStream fis4 = SampleJUnitTest.class.getResourceAsStream("/ECA_OAM_VF.yaml");
- readPayload(inputArtifacts,fis4, "ECA_OAM_VF.yaml");
+ readPayloadFromResource(inputArtifacts, "ECA_OAM_VF.yaml");
- InputStream fis5 = SampleJUnitTest.class.getResourceAsStream("/MMSC_Sevice_07_25_16.yaml");
- readPayload(inputArtifacts,fis5, "MMSC_Sevice_07_25_16.yaml");
+ readPayloadFromResource(inputArtifacts, "MMSC_Sevice_07_25_16.yaml");
- InputStream fis6 = SampleJUnitTest.class.getResourceAsStream("/MMSC_VF.yaml");
- readPayload(inputArtifacts,fis6, "MMSC_VF.yaml");
+ readPayloadFromResource(inputArtifacts, "MMSC_VF.yaml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -310,12 +297,9 @@ public class SampleJUnitTest extends TestCase {
public void testArtifactGenerationDupVFUUID() {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_DupVFUUID.yml");
- readPayload(inputArtifacts,fis1, "vf_vmme_template_DupVFUUID.yml");
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_DupVFUUID.yml");
- fis1.close();
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_DupVFUUID.yml");
- readPayload(inputArtifacts,fis2, "service_vmme_template_DupVFUUID.yml");
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_DupVFUUID.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -346,12 +330,9 @@ public class SampleJUnitTest extends TestCase {
public void testArtifactGenerationDupVFModUUID() {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_DupVFModUUID.yml");
- readPayload(inputArtifacts,fis1, "vf_vmme_template_DupVFModUUID.yml");
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_DupVFModUUID.yml");
- fis1.close();
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_DupVFModUUID.yml");
- readPayload(inputArtifacts,fis2, "service_vmme_template_DupVFModUUID.yml");
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_DupVFModUUID.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -381,12 +362,9 @@ public class SampleJUnitTest extends TestCase {
public void testArtifactGenerationVerifyVFModWithoutVNFC() {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_VerifyVFModWithoutVNFC.yml");
- readPayload(inputArtifacts,fis1, "vf_vmme_template_VerifyVFModWithoutVNFC.yml");
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_VerifyVFModWithoutVNFC.yml");
- fis1.close();
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_VerifyVFModWithoutVNFC.yml");
- readPayload(inputArtifacts,fis2, "service_vmme_template_VerifyVFModWithoutVNFC.yml");
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_VerifyVFModWithoutVNFC.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -416,12 +394,9 @@ public class SampleJUnitTest extends TestCase {
public void testArtifactGenerationVerifyVFModWithInvalidMember() {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_VerifyVFModWithInvalidNo.yml");
- readPayload(inputArtifacts,fis1, "vf_vmme_template_VerifyVFModWithInvalidNo.yml");
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_VerifyVFModWithInvalidNo.yml");
- fis1.close();
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_VerifyVFModWithInvalidNo.yml");
- readPayload(inputArtifacts,fis2, "service_vmme_template_VerifyVFModWithInvalidNo.yml");
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_VerifyVFModWithInvalidNo.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -451,12 +426,9 @@ public class SampleJUnitTest extends TestCase {
public void testArtifactGenerationNullFields() {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_NullFields.yml");
- readPayload(inputArtifacts,fis1, "vf_vmme_template_NullFields.yml");
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_NullFields.yml");
- fis1.close();
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_NullFields.yml");
- readPayload(inputArtifacts,fis2, "service_vmme_template_NullFields.yml");
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_NullFields.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
@@ -477,17 +449,13 @@ public class SampleJUnitTest extends TestCase {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis3 = SampleJUnitTest.class.getResourceAsStream("/CMAUI_VFInvalidFormat.yaml");
- readPayload(inputArtifacts,fis3, "CMAUI_VFInvalidFormat.yaml");
+ readPayloadFromResource(inputArtifacts, "CMAUI_VFInvalidFormat.yaml");
- InputStream fis4 = SampleJUnitTest.class.getResourceAsStream("/ECA_OAM_VFInvalidFormat.yaml");
- readPayload(inputArtifacts,fis4, "ECA_OAM_VFInvalidFormat.yaml");
+ readPayloadFromResource(inputArtifacts, "ECA_OAM_VFInvalidFormat.yaml");
- InputStream fis5 = SampleJUnitTest.class.getResourceAsStream("/MMSC_Sevice_07_25_16InvalidFormat.yaml");
- readPayload(inputArtifacts,fis5, "MMSC_Sevice_07_25_16InvalidFormat.yaml");
+ readPayloadFromResource(inputArtifacts, "MMSC_Sevice_07_25_16InvalidFormat.yaml");
- InputStream fis6 = SampleJUnitTest.class.getResourceAsStream("/MMSC_VFInvalidFormat.yaml");
- readPayload(inputArtifacts,fis6, "MMSC_VFInvalidFormat.yaml");
+ readPayloadFromResource(inputArtifacts, "MMSC_VFInvalidFormat.yaml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
@@ -507,12 +475,9 @@ public class SampleJUnitTest extends TestCase {
public void testArtifactGenerationMulComp() {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_MulComp.yml");
- readPayload(inputArtifacts,fis1, "vf_vmme_template_MulComp.yml");
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_MulComp.yml");
- fis1.close();
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_MulComp.yml");
- readPayload(inputArtifacts,fis2, "service_vmme_template_MulComp.yml");
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_MulComp.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -543,15 +508,11 @@ public class SampleJUnitTest extends TestCase {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_Orphan.yml");
- readPayload(inputArtifacts,fis1, "vf_vmme_template_Orphan.yml");
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_Orphan.yml");
- fis1.close();
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_Orphan.yml");
- readPayload(inputArtifacts,fis2, "service_vmme_template_Orphan.yml");
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_Orphan.yml");
- InputStream fis4 = SampleJUnitTest.class.getResourceAsStream("/ECA_OAM_VFOrphan.yaml");
- readPayload(inputArtifacts,fis4, "ECA_OAM_VFOrphan.yaml");
+ readPayloadFromResource(inputArtifacts, "ECA_OAM_VFOrphan.yaml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -583,10 +544,7 @@ public class SampleJUnitTest extends TestCase {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_MissingVFTemplate.yml");
- readPayload(inputArtifacts,fis1, "service_vmme_template_MissingVFTemplate.yml");
-
- fis1.close();
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_MissingVFTemplate.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -618,17 +576,13 @@ public class SampleJUnitTest extends TestCase {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis3 = SampleJUnitTest.class.getResourceAsStream("/CMAUI_VFMissingVFModule.yaml");
- readPayload(inputArtifacts,fis3, "CMAUI_VFMissingVFModule.yaml");
+ readPayloadFromResource(inputArtifacts, "CMAUI_VFMissingVFModule.yaml");
- InputStream fis4 = SampleJUnitTest.class.getResourceAsStream("/ECA_OAM_VFMissingVFModule.yaml");
- readPayload(inputArtifacts,fis4, "ECA_OAM_VFMissingVFModule.yaml");
+ readPayloadFromResource(inputArtifacts, "ECA_OAM_VFMissingVFModule.yaml");
- InputStream fis5 = SampleJUnitTest.class.getResourceAsStream("/MMSC_Sevice_07_25_16MissingVFModule.yaml");
- readPayload(inputArtifacts,fis5, "MMSC_Sevice_07_25_16MissingVFModule.yaml");
+ readPayloadFromResource(inputArtifacts, "MMSC_Sevice_07_25_16MissingVFModule.yaml");
- InputStream fis6 = SampleJUnitTest.class.getResourceAsStream("/MMSC_VFMissingVFModule.yaml");
- readPayload(inputArtifacts,fis6, "MMSC_VFMissingVFModule.yaml");
+ readPayloadFromResource(inputArtifacts, "MMSC_VFMissingVFModule.yaml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -680,12 +634,9 @@ public class SampleJUnitTest extends TestCase {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_SingleVFVFMod.yml");
- readPayload(inputArtifacts,fis1, "vf_vmme_template_SingleVFVFMod.yml");
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_SingleVFVFMod.yml");
- fis1.close();
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_SingleVFVFMod.yml");
- readPayload(inputArtifacts,fis2, "service_vmme_template_SingleVFVFMod.yml");
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_SingleVFVFMod.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
GenerationData data = obj.generateArtifact(inputArtifacts, "",additionalParams);
@@ -705,15 +656,11 @@ public class SampleJUnitTest extends TestCase {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/ServiceWithNodetemplate.yml");
- readPayload(inputArtifacts,fis1, "ServiceWithNodetemplate.yml");
+ readPayloadFromResource(inputArtifacts, "ServiceWithNodetemplate.yml");
- fis1.close();
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/Resource0-template.yml");
- readPayload(inputArtifacts,fis2, "Resource0-template.yml");
+ readPayloadFromResource(inputArtifacts, "Resource0-template.yml");
- InputStream fis3 = SampleJUnitTest.class.getResourceAsStream("/Resource1-template.yml");
- readPayload(inputArtifacts,fis3, "Resource1-template.yml");
+ readPayloadFromResource(inputArtifacts, "Resource1-template.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -747,10 +694,7 @@ public class SampleJUnitTest extends TestCase {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/Service0-template.yml");
- readPayload(inputArtifacts,fis1, "Service0-template.yml");
-
- fis1.close();
+ readPayloadFromResource(inputArtifacts, "Service0-template.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -784,10 +728,7 @@ public class SampleJUnitTest extends TestCase {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/Service0-templateMoreThan256.yml");
- readPayload(inputArtifacts,fis1, "Service0-templateMoreThan256.yml");
-
- fis1.close();
+ readPayloadFromResource(inputArtifacts, "Service0-templateMoreThan256.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -825,17 +766,11 @@ public class SampleJUnitTest extends TestCase {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_DiffVerOfSameVF.yml");
- readPayload(inputArtifacts,fis1, "service_vmme_template_DiffVerOfSameVF.yml");
- fis1.close();
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_DiffVerOfSameVF.yml");
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_DiffVerOfSameVF_1.yml");
- readPayload(inputArtifacts,fis2, "vf_vmme_template_DiffVerOfSameVF_1.yml");
- fis2.close();
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_DiffVerOfSameVF_1.yml");
- InputStream fis3 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_DiffVerOfSameVF_2.yml");
- readPayload(inputArtifacts,fis3, "vf_vmme_template_DiffVerOfSameVF_2.yml");
- fis3.close();
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_DiffVerOfSameVF_2.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -869,13 +804,9 @@ public class SampleJUnitTest extends TestCase {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_DiffVerOfSameVFModWithSameInvId.yml");
- readPayload(inputArtifacts,fis1, "service_vmme_template_DiffVerOfSameVFModWithSameInvId.yml");
- fis1.close();
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_DiffVerOfSameVFModWithSameInvId.yml");
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_DiffVerOfSameVFModWithSameInvId.yml");
- readPayload(inputArtifacts,fis2, "vf_vmme_template_DiffVerOfSameVFModWithSameInvId.yml");
- fis2.close();
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_DiffVerOfSameVFModWithSameInvId.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -909,22 +840,13 @@ public class SampleJUnitTest extends TestCase {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_WithL3Network.yml");
- readPayload(inputArtifacts,fis1, "service_vmme_template_WithL3Network.yml");
- fis1.close();
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_WithL3Network.yml");
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_WithL3Network.yml");
- readPayload(inputArtifacts,fis2, "vf_vmme_template_WithL3Network.yml");
- fis2.close();
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_WithL3Network.yml");
- InputStream fis3 = SampleJUnitTest.class.getResourceAsStream("/resource-AllottedResource-template_WithL3Network.yml");
- readPayload(inputArtifacts,fis3, "resource-AllottedResource-template_WithL3Network.yml");
- fis3.close();
+ readPayloadFromResource(inputArtifacts, "resource-AllottedResource-template_WithL3Network.yml");
- InputStream fis4 = SampleJUnitTest.class.getResourceAsStream
- ("/resource-Extvl-template_WithL3Network.yml");
- readPayload(inputArtifacts,fis4, "resource-Extvl-template_WithL3Network.yml");
- fis4.close();
+ readPayloadFromResource(inputArtifacts, "resource-Extvl-template_WithL3Network.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -958,22 +880,13 @@ public class SampleJUnitTest extends TestCase {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_WithDupL3Network.yml");
- readPayload(inputArtifacts,fis1, "service_vmme_template_WithDupL3Network.yml");
- fis1.close();
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_WithDupL3Network.yml");
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_WithDupL3Network.yml");
- readPayload(inputArtifacts,fis2, "vf_vmme_template_WithDupL3Network.yml");
- fis2.close();
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_WithDupL3Network.yml");
- InputStream fis3 = SampleJUnitTest.class.getResourceAsStream("/resource-AllottedResource-template_WithDupL3Network.yml");
- readPayload(inputArtifacts,fis3, "resource-AllottedResource-template_WithDupL3Network.yml");
- fis3.close();
+ readPayloadFromResource(inputArtifacts, "resource-AllottedResource-template_WithDupL3Network.yml");
- InputStream fis4 = SampleJUnitTest.class.getResourceAsStream
- ("/resource-Extvl-template_WithDupL3Network.yml");
- readPayload(inputArtifacts,fis4, "resource-Extvl-template_WithDupL3Network.yml");
- fis4.close();
+ readPayloadFromResource(inputArtifacts, "resource-Extvl-template_WithDupL3Network.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -1007,17 +920,11 @@ public class SampleJUnitTest extends TestCase {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_WithL3NetworkInVFMod.yml");
- readPayload(inputArtifacts,fis1, "service_vmme_template_WithL3NetworkInVFMod.yml");
- fis1.close();
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_WithL3NetworkInVFMod.yml");
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_WithL3NetworkInVFMod.yml");
- readPayload(inputArtifacts,fis2, "vf_vmme_template_WithL3NetworkInVFMod.yml");
- fis2.close();
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_WithL3NetworkInVFMod.yml");
- InputStream fis3 = SampleJUnitTest.class.getResourceAsStream("/resource-AllottedResource-template_WithL3NetworkInVFMod.yml");
- readPayload(inputArtifacts,fis3, "resource-AllottedResource-template_WithL3NetworkInVFMod.yml");
- fis3.close();
+ readPayloadFromResource(inputArtifacts, "resource-AllottedResource-template_WithL3NetworkInVFMod.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -1051,28 +958,15 @@ public class SampleJUnitTest extends TestCase {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_WithDiffVersionOfSameL3Network.yml");
- readPayload(inputArtifacts,fis1, "service_vmme_template_WithDiffVersionOfSameL3Network.yml");
- fis1.close();
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_WithDiffVersionOfSameL3Network.yml");
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_WithDiffVersionOfSameL3Network.yml");
- readPayload(inputArtifacts,fis2, "vf_vmme_template_WithDiffVersionOfSameL3Network.yml");
- fis2.close();
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_WithDiffVersionOfSameL3Network.yml");
- InputStream fis3 = SampleJUnitTest.class.getResourceAsStream("/resource-AllottedResource-template_WithDiffVersionOfSameL3Network.yml");
- readPayload(inputArtifacts,fis3, "resource-AllottedResource-template_WithDiffVersionOfSameL3Network.yml");
- fis3.close();
+ readPayloadFromResource(inputArtifacts, "resource-AllottedResource-template_WithDiffVersionOfSameL3Network.yml");
- InputStream fis4 = SampleJUnitTest.class.getResourceAsStream
- ("/resource-Extvl-template_WithDiffVersionOfSameL3Network.yml");
- readPayload(inputArtifacts,fis4, "resource-Extvl-template_WithDiffVersionOfSameL3Network.yml");
- fis4.close();
+ readPayloadFromResource(inputArtifacts, "resource-Extvl-template_WithDiffVersionOfSameL3Network.yml");
- InputStream fis5 = SampleJUnitTest.class.getResourceAsStream
- ("/resource-Extvl-template_1_WithDiffVersionOfSameL3Network.yml");
- readPayload(inputArtifacts,fis5,
- "resource-Extvl-template_1_WithDiffVersionOfSameL3Network.yml");
- fis5.close();
+ readPayloadFromResource(inputArtifacts, "resource-Extvl-template_1_WithDiffVersionOfSameL3Network.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -1105,15 +999,10 @@ public class SampleJUnitTest extends TestCase {
public void testArtifactGenerationWithInvIdGreaterThanSpecifiedLimit() {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_WithInvIdGreaterThanSpecifiedLimit.yml");
- readPayload(inputArtifacts,fis1, "vf_vmme_template_WithInvIdGreaterThanSpecifiedLimit" +
- ".yml");
- fis1.close();
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_WithInvIdGreaterThanSpecifiedLimit.yml");
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_WithInvIdGreaterThanSpecifiedLimit.yml");
- readPayload(inputArtifacts,fis2, "service_vmme_template_WithInvIdGreaterThanSpecifiedLimit.yml");
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_WithInvIdGreaterThanSpecifiedLimit.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
- fis2.close();
GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
Assert.assertEquals(false,data.getErrorData().isEmpty());
@@ -1132,15 +1021,10 @@ public class SampleJUnitTest extends TestCase {
public void testArtifactGenerationWithInvIdLesserThanSpecifiedLimit() {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_WithInvIdLesserThanSpecifiedLimit.yml");
- readPayload(inputArtifacts,fis1, "vf_vmme_template_WithInvIdLesserThanSpecifiedLimit" +
- ".yml");
- fis1.close();
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_WithInvIdLesserThanSpecifiedLimit.yml");
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_WithInvIdLesserThanSpecifiedLimit.yml");
- readPayload(inputArtifacts,fis2, "service_vmme_template_WithInvIdLesserThanSpecifiedLimit.yml");
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_WithInvIdLesserThanSpecifiedLimit.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
- fis2.close();
GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
Assert.assertEquals(false,data.getErrorData().isEmpty());
@@ -1162,14 +1046,9 @@ public class SampleJUnitTest extends TestCase {
String configLoc = System.getProperty(ARTIFACTGENERATOR_CONFIG);
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_NoSystemPropConfigured.yml");
- readPayload(inputArtifacts,fis1, "vf_vmme_template_NoSystemPropConfigured" +
- ".yml");
- fis1.close();
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_NoSystemPropConfigured.yml");
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_NoSystemPropConfigured.yml");
- readPayload(inputArtifacts,fis2, "service_vmme_template_NoSystemPropConfigured.yml");
- fis2.close();
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_NoSystemPropConfigured.yml");
System.clearProperty(ARTIFACTGENERATOR_CONFIG);
@@ -1192,14 +1071,9 @@ public class SampleJUnitTest extends TestCase {
String configLoc = System.getProperty(ARTIFACTGENERATOR_CONFIG);
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_NoSystemPropConfigured.yml");
- readPayload(inputArtifacts,fis1, "vf_vmme_template_NoSystemPropConfigured" +
- ".yml");
- fis1.close();
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_NoSystemPropConfigured.yml");
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_NoSystemPropConfigured.yml");
- readPayload(inputArtifacts,fis2, "service_vmme_template_NoSystemPropConfigured.yml");
- fis2.close();
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_NoSystemPropConfigured.yml");
System.setProperty(ARTIFACTGENERATOR_CONFIG,configLoc + File.separator + "testErrorWhenNoFileAtConfigLocation");
Map<String, Model> outputArtifactMap = new HashMap<>();
@@ -1223,14 +1097,9 @@ public class SampleJUnitTest extends TestCase {
loadConfig(ArtifactGenerationServiceTest.properties);
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_NoSystemPropConfigured.yml");
- readPayload(inputArtifacts,fis1, "vf_vmme_template_NoSystemPropConfigured" +
- ".yml");
- fis1.close();
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_NoSystemPropConfigured.yml");
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_NoSystemPropConfigured.yml");
- readPayload(inputArtifacts,fis2, "service_vmme_template_NoSystemPropConfigured.yml");
- fis2.close();
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_NoSystemPropConfigured.yml");
Map<String, Model> outputArtifactMap = new HashMap<>();
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
@@ -1254,14 +1123,9 @@ public class SampleJUnitTest extends TestCase {
public void testArtifactGenerationWithUpdatedUUIDInConfig() throws Exception {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_WithUpdatedUUIDInConfig.yml");
- readPayload(inputArtifacts,fis1, "vf_vmme_template_WithUpdatedUUIDInConfig" +
- ".yml");
- fis1.close();
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_WithUpdatedUUIDInConfig.yml");
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_WithUpdatedUUIDInConfig.yml");
- readPayload(inputArtifacts,fis2, "service_vmme_template_WithUpdatedUUIDInConfig.yml");
- fis2.close();
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_WithUpdatedUUIDInConfig.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, additionalParams);
@@ -1301,12 +1165,9 @@ public class SampleJUnitTest extends TestCase {
public void testArtifactGenerationVerifyMandatoryParameterServiceVersion() {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_VerifyMandatoryParameterServiceVersion.yml");
- readPayload(inputArtifacts, fis1, "vf_vmme_template_VerifyMandatoryParameterServiceVersion.yml");
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_VerifyMandatoryParameterServiceVersion.yml");
- fis1.close();
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_VerifyMandatoryParameterServiceVersion.yml");
- readPayload(inputArtifacts, fis2, "service_vmme_template_VerifyMandatoryParameterServiceVersion.yml");
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_VerifyMandatoryParameterServiceVersion.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
GenerationData data = obj.generateArtifact(inputArtifacts, generatorConfig, new HashMap<String, String>());
@@ -1323,12 +1184,9 @@ public class SampleJUnitTest extends TestCase {
public void testArtifactGenerationVerifyServiceVersionFormat() {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_VerifyServiceVersionFormat.yml");
- readPayload(inputArtifacts, fis1, "vf_vmme_template_VerifyServiceVersionFormat.yml");
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_VerifyServiceVersionFormat.yml");
- fis1.close();
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_VerifyServiceVersionFormat.yml");
- readPayload(inputArtifacts, fis2, "service_vmme_template_VerifyServiceVersionFormat.yml");
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_VerifyServiceVersionFormat.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
additionalParams.put(AdditionalParams.ServiceVersion.getName(),"1");
@@ -1363,12 +1221,9 @@ public class SampleJUnitTest extends TestCase {
public void testArtifactGenerationVerifyServiceVersion() {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_VerifyServiceVersion.yml");
- readPayload(inputArtifacts, fis1, "vf_vmme_template_VerifyServiceVersion.yml");
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_VerifyServiceVersion.yml");
- fis1.close();
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_VerifyServiceVersion.yml");
- readPayload(inputArtifacts, fis2, "service_vmme_template_VerifyServiceVersion.yml");
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_VerifyServiceVersion.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -1405,14 +1260,10 @@ public class SampleJUnitTest extends TestCase {
public void testArtifactGenerationVerifyResourceVersionFormat() {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_VerifyResourceVersionFormat.yml");
- readPayload(inputArtifacts, fis1, "vf_vmme_template_VerifyResourceVersionFormat.yml");
- fis1.close();
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_VerifyResourceVersionFormat.yml");
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_VerifyResourceVersionFormat1.yml");
- readPayload(inputArtifacts, fis2, "service_vmme_template_VerifyResourceVersionFormat1.yml");
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_VerifyResourceVersionFormat1.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
- fis2.close();
List<ToscaTemplate> toscas = new LinkedList();
for (Artifact inputArtifact : inputArtifacts) {
@@ -1428,9 +1279,7 @@ public class SampleJUnitTest extends TestCase {
inputArtifacts.remove(1);
- InputStream fis3 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_VerifyResourceVersionFormat2.yml");
- readPayload(inputArtifacts, fis3, "service_vmme_template_VerifyResourceVersionFormat2.yml");
- fis3.close();
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_VerifyResourceVersionFormat2.yml");
GenerationData data2 = obj.generateArtifact(inputArtifacts, generatorConfig,
additionalParams);
List<Artifact> resultData2 = data2.getResultData();
@@ -1448,12 +1297,9 @@ public class SampleJUnitTest extends TestCase {
public void testArtifactGenerationVerifyMandatoryParameterResourceVersion() {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/vf_vmme_template_VerifyMandatoryParameterResourceVersion.yml");
- readPayload(inputArtifacts, fis1, "vf_vmme_template_VerifyMandatoryParameterResourceVersion.yml");
+ readPayloadFromResource(inputArtifacts, "vf_vmme_template_VerifyMandatoryParameterResourceVersion.yml");
- fis1.close();
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/service_vmme_template_VerifyMandatoryParameterResourceVersion.yml");
- readPayload(inputArtifacts, fis2, "service_vmme_template_VerifyMandatoryParameterResourceVersion.yml");
+ readPayloadFromResource(inputArtifacts, "service_vmme_template_VerifyMandatoryParameterResourceVersion.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
for (Artifact inputArtifact : inputArtifacts) {
@@ -1474,13 +1320,9 @@ public class SampleJUnitTest extends TestCase {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/service-ServiceWithAllottedResourceIpmux-template.yml");
- readPayload(inputArtifacts, fis1, "service-ServiceWithAllottedResourceIpmux-template.yml");
- fis1.close();
+ readPayloadFromResource(inputArtifacts, "service-ServiceWithAllottedResourceIpmux-template.yml");
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/resource-AllottedResource-template_IpMux.yml");
- readPayload(inputArtifacts, fis2, "resource-AllottedResource-template_IpMux.yml");
- fis2.close();
+ readPayloadFromResource(inputArtifacts, "resource-AllottedResource-template_IpMux.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -1505,14 +1347,9 @@ public class SampleJUnitTest extends TestCase {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream
- ("/service-ServiceWithAllottedResourceIpmux-template_WithGroups.yml");
- readPayload(inputArtifacts, fis1, "service-ServiceWithAllottedResourceIpmux-template_WithGroups.yml");
- fis1.close();
+ readPayloadFromResource(inputArtifacts, "service-ServiceWithAllottedResourceIpmux-template_WithGroups.yml");
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/resource-AllottedResource-template_IpMux_WithGroups.yml");
- readPayload(inputArtifacts, fis2, "resource-AllottedResource-template_IpMux_WithGroups.yml");
- fis2.close();
+ readPayloadFromResource(inputArtifacts, "resource-AllottedResource-template_IpMux_WithGroups.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -1545,17 +1382,11 @@ public class SampleJUnitTest extends TestCase {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/service-ServiceWithAllottedResourcesIpMuxSameInvariant-template.yml");
- readPayload(inputArtifacts, fis1, "service-ServiceWithAllottedResourcesIpMuxSameInvariant-template.yml");
- fis1.close();
+ readPayloadFromResource(inputArtifacts, "service-ServiceWithAllottedResourcesIpMuxSameInvariant-template.yml");
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/resource-AllottedResource1SameInvariant-IpMux-template.yml");
- readPayload(inputArtifacts, fis2, "resource-AllottedResource1SameInvariant-IpMux-template.yml");
- fis2.close();
+ readPayloadFromResource(inputArtifacts, "resource-AllottedResource1SameInvariant-IpMux-template.yml");
- InputStream fis3 = SampleJUnitTest.class.getResourceAsStream("/resource-AllottedResource2SameInvariant-IpMux-template.yml");
- readPayload(inputArtifacts, fis3, "resource-AllottedResource2SameInvariant-IpMux-template.yml");
- fis3.close();
+ readPayloadFromResource(inputArtifacts, "resource-AllottedResource2SameInvariant-IpMux-template.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -1589,13 +1420,9 @@ public class SampleJUnitTest extends TestCase {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/service-ServiceWithAllottedResourcesIpMuxSameInvariantSameVers-template.yml");
- readPayload(inputArtifacts, fis1, "service-ServiceWithAllottedResourcesIpMuxSameInvariantSameVers-template.yml");
- fis1.close();
+ readPayloadFromResource(inputArtifacts, "service-ServiceWithAllottedResourcesIpMuxSameInvariantSameVers-template.yml");
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/resource-AllottedResourceSameInvariantSameVers-IpMux-template.yml");
- readPayload(inputArtifacts, fis2, "resource-AllottedResourceSameInvariantSameVers-IpMux-template.yml");
- fis2.close();
+ readPayloadFromResource(inputArtifacts, "resource-AllottedResourceSameInvariantSameVers-IpMux-template.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -1629,14 +1456,11 @@ public class SampleJUnitTest extends TestCase {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/service-Allottedipmux-template.yml");
- readPayload(inputArtifacts, fis2, "service-Allottedipmux-template.yml");
+ readPayloadFromResource(inputArtifacts, "service-Allottedipmux-template.yml");
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/resource-IpMuxDemux-template.yml");
- readPayload(inputArtifacts, fis1, "resource-IpMuxDemux-template.yml");
+ readPayloadFromResource(inputArtifacts, "resource-IpMuxDemux-template.yml");
- InputStream fis3 = SampleJUnitTest.class.getResourceAsStream("/resource-TunnelXconn-template.yml");
- readPayload(inputArtifacts, fis3, "resource-TunnelXconn-template.yml");
+ readPayloadFromResource(inputArtifacts, "resource-TunnelXconn-template.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -1669,22 +1493,15 @@ public class SampleJUnitTest extends TestCase {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/service-SdWan-template_WithOutDepSerId.yml");
- readPayload(inputArtifacts, fis2, "service-SdWan-template_WithOutDepSerId.yml");
+ readPayloadFromResource(inputArtifacts, "service-SdWan-template_WithOutDepSerId.yml");
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/resource-VhnfNonHeat-template_WithOutDepSerId.yml");
- readPayload(inputArtifacts, fis1, "resource-VhnfNonHeat-template_WithOutDepSerId.yml");
+ readPayloadFromResource(inputArtifacts, "resource-VhnfNonHeat-template_WithOutDepSerId.yml");
- InputStream fis3 = SampleJUnitTest.class.getResourceAsStream("/resource-TunnelXconn-template_WithOutDepSerId.yml");
- readPayload(inputArtifacts, fis3, "resource-TunnelXconn-template_WithOutDepSerId.yml");
+ readPayloadFromResource(inputArtifacts, "resource-TunnelXconn-template_WithOutDepSerId.yml");
- InputStream fis4 = SampleJUnitTest.class.getResourceAsStream
- ("/resource-ServiceAdmin-template_WithOutDepSerId.yml");
- readPayload(inputArtifacts, fis4, "resource-ServiceAdmin-template_WithOutDepSerId.yml");
+ readPayloadFromResource(inputArtifacts, "resource-ServiceAdmin-template_WithOutDepSerId.yml");
- InputStream fis5 = SampleJUnitTest.class.getResourceAsStream
- ("/resource-IpMuxDemux-template_WithOutDepSerId.yml");
- readPayload(inputArtifacts, fis5, "resource-IpMuxDemux-template_WithOutDepSerId.yml");
+ readPayloadFromResource(inputArtifacts, "resource-IpMuxDemux-template_WithOutDepSerId.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -1707,22 +1524,15 @@ public class SampleJUnitTest extends TestCase {
try {
List<Artifact> inputArtifacts = new ArrayList();
- InputStream fis2 = SampleJUnitTest.class.getResourceAsStream("/service-SdWan-template_AllRes_VF.yml");
- readPayload(inputArtifacts, fis2, "service-SdWan-template_AllRes_VF.yml");
+ readPayloadFromResource(inputArtifacts, "service-SdWan-template_AllRes_VF.yml");
- InputStream fis1 = SampleJUnitTest.class.getResourceAsStream("/resource-VhnfNonHeat-template_AllRes_VF.yml");
- readPayload(inputArtifacts, fis1, "resource-VhnfNonHeat-template_AllRes_VF.yml");
+ readPayloadFromResource(inputArtifacts, "resource-VhnfNonHeat-template_AllRes_VF.yml");
- InputStream fis3 = SampleJUnitTest.class.getResourceAsStream("/resource-TunnelXconn-template_AllRes_VF.yml");
- readPayload(inputArtifacts, fis3, "resource-TunnelXconn-template_AllRes_VF.yml");
+ readPayloadFromResource(inputArtifacts, "resource-TunnelXconn-template_AllRes_VF.yml");
- InputStream fis4 = SampleJUnitTest.class.getResourceAsStream
- ("/resource-ServiceAdmin-template_AllRes_VF.yml");
- readPayload(inputArtifacts, fis4, "resource-ServiceAdmin-template_AllRes_VF.yml");
+ readPayloadFromResource(inputArtifacts, "resource-ServiceAdmin-template_AllRes_VF.yml");
- InputStream fis5 = SampleJUnitTest.class.getResourceAsStream
- ("/resource-IpMuxDemux-template_AllRes_VF.yml");
- readPayload(inputArtifacts, fis5, "resource-IpMuxDemux-template_AllRes_VF.yml");
+ readPayloadFromResource(inputArtifacts, "resource-IpMuxDemux-template_AllRes_VF.yml");
ArtifactGenerationServiceImpl obj = new ArtifactGenerationServiceImpl();
List<ToscaTemplate> toscas = new LinkedList();
@@ -1802,4 +1612,10 @@ public class SampleJUnitTest extends TestCase {
}
}*/
+ private void readPayloadFromResource(List<Artifact> inputArtifacts, String fileName) throws IOException {
+
+ try (InputStream fis = SampleJUnitTest.class.getResourceAsStream("/" + fileName)) {
+ readPayload(inputArtifacts, fis, fileName);
+ }
+ }
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java
index d399469745..2f6d298f01 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java
@@ -35,29 +35,25 @@ import org.openecomp.sdc.common.errors.ValidationErrorBuilder;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import javax.validation.Path;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
public class DefaultExceptionMapper implements ExceptionMapper<Exception> {
private static final String ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE =
"errorCodesToResponseStatusMapping.json";
@SuppressWarnings("unchecked")
private static Map<String, String> errorCodeToResponseStatus =
- JsonUtil.json2Object(FileUtils
- .getFileInputStream(ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE), Map.class);
+ FileUtils.readViaInputStream(ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE,
+ stream -> JsonUtil.json2Object(stream, Map.class));
+
private static Logger logger = (Logger) LoggerFactory.getLogger(DefaultExceptionMapper.class);
@Override
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java
index 07322c626b..f4d6209eec 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java
@@ -59,26 +59,24 @@ public class CommonUtil {
private static FileContentHandler getFileContentMapFromOrchestrationCandidateZipAndValidateNoFolders(
byte[] uploadFileData)
throws IOException {
- ZipEntry zipEntry;
+
List<String> folderList = new ArrayList<>();
FileContentHandler mapFileContent = new FileContentHandler();
- try {
- ZipInputStream inputZipStream;
- byte[] fileByteContent;
+ try (ZipInputStream inputZipStream = new ZipInputStream(new ByteArrayInputStream(uploadFileData))) {
+
String currentEntryName;
- inputZipStream = new ZipInputStream(new ByteArrayInputStream(uploadFileData));
+ ZipEntry zipEntry;
while ((zipEntry = inputZipStream.getNextEntry()) != null) {
- currentEntryName = zipEntry.getName();
- // else, get the file content (as byte array) and save it in a map.
- fileByteContent = FileUtils.toByteArray(inputZipStream);
+ currentEntryName = zipEntry.getName();
int index = lastIndexFileSeparatorIndex(currentEntryName);
if (index != -1) { //todo ?
folderList.add(currentEntryName);
} else {
- mapFileContent.addFile(currentEntryName, fileByteContent);
+ // else, get the file content (as byte array) and save it in a map.
+ mapFileContent.addFile(currentEntryName, FileUtils.toByteArray(inputZipStream));
}
}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-core/src/main/java/org/openecomp/core/factory/FactoriesConfigImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-core/src/main/java/org/openecomp/core/factory/FactoriesConfigImpl.java
index 173f9b15b1..b9d03f4d1a 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-core/src/main/java/org/openecomp/core/factory/FactoriesConfigImpl.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-core/src/main/java/org/openecomp/core/factory/FactoriesConfigImpl.java
@@ -25,7 +25,9 @@ import org.openecomp.core.factory.api.FactoriesConfiguration;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.utilities.json.JsonUtil;
+import java.io.IOException;
import java.io.InputStream;
+import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -50,12 +52,16 @@ public final class FactoriesConfigImpl implements FactoriesConfiguration {
}
private void init() {
- List<InputStream> factoryConfigIsList = FileUtils.getFileInputStreams(FACTORY_CONFIG_FILE_NAME);
- for (InputStream factoryConfigIs : factoryConfigIsList) {
- factoryMap.putAll(JsonUtil.json2Object(factoryConfigIs, Map.class));
- }
- }
+ List<URL> factoryConfigUrlList = FileUtils.getAllLocations(FACTORY_CONFIG_FILE_NAME);
+ for (URL factoryConfigUrl : factoryConfigUrlList) {
+ try (InputStream stream = factoryConfigUrl.openStream()) {
+ factoryMap.putAll(JsonUtil.json2Object(stream, Map.class));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-api/src/main/java/org/openecomp/core/util/UniqueValueUtil.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-api/src/main/java/org/openecomp/core/util/UniqueValueUtil.java
index d2dee5e512..dce34a1c96 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-api/src/main/java/org/openecomp/core/util/UniqueValueUtil.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-api/src/main/java/org/openecomp/core/util/UniqueValueUtil.java
@@ -27,7 +27,6 @@ import org.openecomp.core.utilities.CommonMethods;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
-import org.openecomp.sdc.common.utils.CommonUtil;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import java.util.Optional;
@@ -95,9 +94,10 @@ public class UniqueValueUtil {
mdcDataDebugMessage.debugEntryMessage(null, null);
- if ((newValue != null && oldValue != null
- && !newValue.toLowerCase().equals(oldValue.toLowerCase()))
- || newValue == null || oldValue == null) {
+ boolean nonEqual = (newValue != null) && (oldValue != null)
+ && !newValue.toLowerCase().equals(oldValue.toLowerCase());
+
+ if (nonEqual || newValue == null || oldValue == null) {
createUniqueValue(type, CommonMethods.concat(uniqueContext, new String[]{newValue}));
deleteUniqueValue(type, CommonMethods.concat(uniqueContext, new String[]{oldValue}));
}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/CassandraUtils.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/CassandraUtils.java
index 2a88d0e521..7a70900873 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/CassandraUtils.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/CassandraUtils.java
@@ -23,7 +23,6 @@ package org.openecomp.core.nosqldb.util;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.utilities.json.JsonUtil;
-import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
@@ -49,10 +48,12 @@ public class CassandraUtils {
* @return the statement
*/
public static String getStatement(String statementName) {
+
if (statementMap.size() == 0) {
- InputStream statementJson = FileUtils.getFileInputStream(CASSANDRA_STATEMENT_DEFINITION_FILE);
- statementMap = JsonUtil.json2Object(statementJson, Map.class);
+ statementMap = FileUtils.readViaInputStream(CASSANDRA_STATEMENT_DEFINITION_FILE,
+ stream -> JsonUtil.json2Object(stream, Map.class));
}
+
return statementMap.get(statementName);
}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileUtils.java b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileUtils.java
index 87ce8d37c3..e04f02cce5 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileUtils.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileUtils.java
@@ -28,9 +28,12 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
-import java.util.ArrayList;
+import java.util.Collections;
import java.util.Enumeration;
+import java.util.LinkedList;
import java.util.List;
+import java.util.Objects;
+import java.util.function.Function;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@@ -40,38 +43,29 @@ import java.util.zip.ZipInputStream;
public class FileUtils {
/**
- * Gets file input stream.
+ * Allows to consume an input stream open against a resource with a given file name.
*
* @param fileName the file name
- * @return the file input stream
+ * @param function logic to be applied to the input stream
*/
- public static InputStream getFileInputStream(String fileName) {
- URL urlFile = FileUtils.class.getClassLoader().getResource(fileName);
- InputStream is;
- try {
- assert urlFile != null;
- is = urlFile.openStream();
- } catch (IOException exception) {
- throw new RuntimeException(exception);
- }
- return is;
+ public static <T> T readViaInputStream(String fileName, Function<InputStream, T> function) {
+ return readViaInputStream(FileUtils.class.getClassLoader().getResource(fileName), function);
}
/**
- * Gets file input stream.
+ * Allows to consume an input stream open against a resource with a given URL.
*
* @param urlFile the url file
- * @return the file input stream
+ * @param function logic to be applied to the input stream
*/
- public static InputStream getFileInputStream(URL urlFile) {
- InputStream is;
- try {
- assert urlFile != null;
- is = urlFile.openStream();
+ public static <T> T readViaInputStream(URL urlFile, Function<InputStream, T> function) {
+
+ Objects.requireNonNull(urlFile);
+ try (InputStream is = urlFile.openStream()) {
+ return function.apply(is);
} catch (IOException exception) {
throw new RuntimeException(exception);
}
- return is;
}
/**
@@ -80,24 +74,23 @@ public class FileUtils {
* @param fileName the file name
* @return the file input streams
*/
- public static List<InputStream> getFileInputStreams(String fileName) {
+ public static List<URL> getAllLocations(String fileName) {
+
+ List<URL> urls = new LinkedList<>();
Enumeration<URL> urlFiles;
- List<InputStream> streams = new ArrayList<>();
- InputStream is;
- URL url;
+
try {
urlFiles = FileUtils.class.getClassLoader().getResources(fileName);
while (urlFiles.hasMoreElements()) {
- url = urlFiles.nextElement();
- is = url.openStream();
- streams.add(is);
+ urls.add(urlFiles.nextElement());
}
} catch (IOException exception) {
throw new RuntimeException(exception);
}
- return streams;
+
+ return urls.isEmpty() ? Collections.emptyList() : Collections.unmodifiableList(urls);
}
/**
@@ -210,25 +203,22 @@ public class FileUtils {
* @throws IOException the io exception
*/
public static FileContentHandler getFileContentMapFromZip(byte[] zipData) throws IOException {
- ZipEntry zipEntry;
- FileContentHandler mapFileContent = new FileContentHandler();
- try {
- ZipInputStream inputZipStream;
- byte[] fileByteContent;
- String currentEntryName;
- inputZipStream = new ZipInputStream(new ByteArrayInputStream(zipData));
+ try (ZipInputStream inputZipStream = new ZipInputStream(new ByteArrayInputStream(zipData))) {
+
+ FileContentHandler mapFileContent = new FileContentHandler();
+
+ ZipEntry zipEntry;
while ((zipEntry = inputZipStream.getNextEntry()) != null) {
- currentEntryName = zipEntry.getName();
- fileByteContent = FileUtils.toByteArray(inputZipStream);
- mapFileContent.addFile(currentEntryName, fileByteContent);
+ mapFileContent.addFile(zipEntry.getName(), FileUtils.toByteArray(inputZipStream));
}
+ return mapFileContent;
+
} catch (RuntimeException exception) {
throw new IOException(exception);
}
- return mapFileContent;
}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/java/org/openecomp/core/utilities/json/JsonSchemaDataGeneratorTest.java b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/java/org/openecomp/core/utilities/json/JsonSchemaDataGeneratorTest.java
index ba34d07034..9b21f632cc 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/java/org/openecomp/core/utilities/json/JsonSchemaDataGeneratorTest.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/java/org/openecomp/core/utilities/json/JsonSchemaDataGeneratorTest.java
@@ -28,14 +28,17 @@ import org.testng.annotations.Test;
public class JsonSchemaDataGeneratorTest {
- public static final String SCHEMA_WITHOUT_DEFAULTS = new String(
- FileUtils.toByteArray(FileUtils.getFileInputStream("jsonUtil/json_schema/aSchema.json")));
- public static final String SCHEMA_WITH_REFS_AND_DEFAULTS = new String(FileUtils.toByteArray(
- FileUtils.getFileInputStream("jsonUtil/json_schema/schemaWithRefsAndDefaults.json")));
- public static final String SCHEMA_WITH_INVALID_DEFAULT = new String(FileUtils.toByteArray(
- FileUtils.getFileInputStream("jsonUtil/json_schema/schemaWithInvalidDefault.json")));
- public static final String SCHEMA_NIC = new String(
- FileUtils.toByteArray(FileUtils.getFileInputStream("jsonUtil/json_schema/nicSchema.json")));
+ public static final String SCHEMA_WITHOUT_DEFAULTS =
+ readFromFile("jsonUtil/json_schema/aSchema.json");
+
+ public static final String SCHEMA_WITH_REFS_AND_DEFAULTS =
+ readFromFile("jsonUtil/json_schema/schemaWithRefsAndDefaults.json");
+
+ public static final String SCHEMA_WITH_INVALID_DEFAULT =
+ readFromFile("jsonUtil/json_schema/schemaWithInvalidDefault.json");
+
+ public static final String SCHEMA_NIC =
+ readFromFile("jsonUtil/json_schema/nicSchema.json");
@Test
public void testSchemaWithoutDefaults() {
@@ -67,4 +70,8 @@ public class JsonSchemaDataGeneratorTest {
JSONObject dataJson = new JSONObject(data);
Assert.assertTrue(expectedData.similar(dataJson));
}
+
+ private static String readFromFile(String filename) {
+ return FileUtils.readViaInputStream(filename, stream -> new String(FileUtils.toByteArray(stream)));
+ }
}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/java/org/openecomp/core/utilities/json/JsonUtilTest.java b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/java/org/openecomp/core/utilities/json/JsonUtilTest.java
index 6b8805797a..d89019baec 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/java/org/openecomp/core/utilities/json/JsonUtilTest.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/test/java/org/openecomp/core/utilities/json/JsonUtilTest.java
@@ -31,10 +31,14 @@ public class JsonUtilTest {
@Test
public void testValidJsonValidate() throws Exception {
- String json =
- new String(FileUtils.toByteArray(FileUtils.getFileInputStream("jsonUtil/json/a.json")));
- String jsonSchema = new String(
- FileUtils.toByteArray(FileUtils.getFileInputStream("jsonUtil/json_schema/aSchema.json")));
+
+
+
+ String json = FileUtils.readViaInputStream("jsonUtil/json/a.json",
+ stream -> new String(FileUtils.toByteArray(stream)));
+
+ String jsonSchema = FileUtils.readViaInputStream("jsonUtil/json_schema/aSchema.json",
+ stream -> new String(FileUtils.toByteArray(stream)));
List<String> validationErrors = JsonUtil.validate(json, jsonSchema);
Assert.assertNull(validationErrors);
@@ -42,10 +46,11 @@ public class JsonUtilTest {
@Test
public void testInValidJsonValidate() throws Exception {
- String json = new String(
- FileUtils.toByteArray(FileUtils.getFileInputStream("jsonUtil/json/a_invalid.json")));
- String jsonSchema = new String(
- FileUtils.toByteArray(FileUtils.getFileInputStream("jsonUtil/json_schema/aSchema.json")));
+
+ String json = FileUtils.readViaInputStream("jsonUtil/json/a_invalid.json",
+ stream -> new String(FileUtils.toByteArray(stream)));
+ String jsonSchema = FileUtils.readViaInputStream("jsonUtil/json_schema/aSchema.json",
+ stream -> new String(FileUtils.toByteArray(stream)));
List<String> validationErrors = JsonUtil.validate(json, jsonSchema);
Assert.assertNotNull(validationErrors);
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java
index 0d4cb9c0ba..0f2c0e7ee1 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java
@@ -20,20 +20,19 @@
package org.openecomp.sdc.healing.impl;
-import org.openecomp.sdc.datatypes.error.ErrorLevel;
-import org.openecomp.sdc.healing.interfaces.Healer;
import org.openecomp.core.utilities.file.FileUtils;
-import org.openecomp.sdc.healing.types.HealCode;
import org.openecomp.core.utilities.json.JsonUtil;
-import org.openecomp.sdc.healing.api.HealingManager;
import org.openecomp.sdc.common.errors.Messages;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.healing.api.HealingManager;
+import org.openecomp.sdc.healing.interfaces.Healer;
+import org.openecomp.sdc.healing.types.HealCode;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
import org.openecomp.sdc.logging.types.LoggerConstants;
import org.openecomp.sdc.logging.types.LoggerErrorCode;
import org.openecomp.sdc.logging.types.LoggerErrorDescription;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
-import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.util.Map;
@@ -77,8 +76,7 @@ public class HealingManagerImpl implements HealingManager {
}
private static Map<String, String> initHealers() {
- InputStream healingConfigurationJson = FileUtils.getFileInputStream(HEALING_CONF_FILE);
- return JsonUtil.json2Object(healingConfigurationJson, Map.class);
+ return FileUtils.readViaInputStream(HEALING_CONF_FILE, stream -> JsonUtil.json2Object(stream, Map.class));
}
private Healer getHealerImplInstance(String implClassName)
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ExternalArtifactEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ExternalArtifactEnricher.java
index fb0622cd67..ffc27106bb 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ExternalArtifactEnricher.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ExternalArtifactEnricher.java
@@ -22,7 +22,6 @@ package org.openecomp.sdc.enrichment.impl.external.artifact;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.utilities.json.JsonUtil;
-import org.openecomp.sdc.common.utils.CommonUtil;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.enrichment.inter.Enricher;
import org.openecomp.sdc.enrichment.inter.ExternalArtifactEnricherInterface;
@@ -30,7 +29,6 @@ import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
-import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.util.Collection;
import java.util.HashMap;
@@ -48,11 +46,9 @@ public class ExternalArtifactEnricher extends Enricher {
private static Logger logger = LoggerFactory.getLogger(ExternalArtifactEnricher.class);
private static Collection<String> getExternalArtifactEnrichedImplClassesList() {
- InputStream externalArtifactEnrichConfigurationJson =
- FileUtils.getFileInputStream(EXTERNAL_ARTIFACT_ENRICH_CONF_FILE);
@SuppressWarnings("unchecked")
- Map<String, String> confFileAsMap =
- JsonUtil.json2Object(externalArtifactEnrichConfigurationJson, Map.class);
+ Map<String, String> confFileAsMap = FileUtils.readViaInputStream(EXTERNAL_ARTIFACT_ENRICH_CONF_FILE,
+ stream -> JsonUtil.json2Object(stream, Map.class));
return confFileAsMap.values();
}
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricherTest.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricherTest.java
index 38f7a1c56e..5f1a67138d 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricherTest.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricherTest.java
@@ -42,7 +42,6 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.io.File;
-import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collection;
@@ -159,8 +158,8 @@ public class MonitoringMibEnricherTest {
}
private ByteBuffer getMibByteBuffer(String fileName) {
- InputStream mibFile = FileUtils.getFileInputStream(this.getClass().getResource(fileName));
- byte[] mibBytes = FileUtils.toByteArray(mibFile);
+ byte[] mibBytes = FileUtils.readViaInputStream(this.getClass().getResource(fileName),
+ stream -> FileUtils.toByteArray(stream));
return ByteBuffer.wrap(mibBytes);
}
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricherTest.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricherTest.java
index aeefc91aa3..2f839a7946 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricherTest.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricherTest.java
@@ -21,14 +21,12 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.io.File;
-import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collection;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.atLeastOnce;
-import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;
public class ProcessArtifactEnricherTest {
@@ -112,8 +110,8 @@ public class ProcessArtifactEnricherTest {
}
private ByteBuffer getMibByteBuffer(String fileName) {
- InputStream mibFile = FileUtils.getFileInputStream(this.getClass().getResource(fileName));
- byte[] mibBytes = FileUtils.toByteArray(mibFile);
+ byte[] mibBytes = FileUtils.readViaInputStream(this.getClass().getResource(fileName),
+ stream -> FileUtils.toByteArray(stream));
return ByteBuffer.wrap(mibBytes);
}
}
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());
}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/TestUtils.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/TestUtils.java
index 5c2f3db833..43f4065044 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/TestUtils.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/TestUtils.java
@@ -97,10 +97,11 @@ public class TestUtils {
Assert.fail("Invalid expected output files directory");
}
for (int i = 0; i < fileList.length; i++) {
- InputStream serviceTemplateInputStream = FileUtils.getFileInputStream(TestUtils.class
- .getClassLoader().getResource(baseDirPath + fileList[i]));
- ServiceTemplate serviceTemplate = toscaExtensionYamlUtil.yamlToObject
- (serviceTemplateInputStream, ServiceTemplate.class);
+
+ URL resource = TestUtils.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) {