summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib
diff options
context:
space:
mode:
authorvempo <vitaliy.emporopulo@amdocs.com>2018-05-10 13:28:06 +0300
committerOren Kleks <orenkle@amdocs.com>2018-05-14 10:02:09 +0000
commita5c4a996f58bfff602124fd4e38c0d2ec70d68f2 (patch)
tree521871829eb7138d6d4c7d47958bcf524e49d6dc /openecomp-be/lib
parentd618ad69ee066ef0aac5a075bc4705543eb87103 (diff)
Refactor HEAT tree test for error handling
Change-Id: Ibd19cecc948896dcca240ab6fc65c394a1034d11 Issue-ID: SDC-836 Signed-off-by: vempo <vitaliy.emporopulo@amdocs.com>
Diffstat (limited to 'openecomp-be/lib')
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/test/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerTest.java33
1 files changed, 12 insertions, 21 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/test/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/test/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerTest.java
index c43c55721e..6e8901c3ce 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/test/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-core/src/test/java/org/openecomp/sdc/heat/services/tree/HeatTreeManagerTest.java
@@ -16,26 +16,21 @@
package org.openecomp.sdc.heat.services.tree;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.Test;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.net.URL;;
-
-
public class HeatTreeManagerTest {
- private Logger logger = LoggerFactory.getLogger(HeatTreeManagerTest.class);
-
@Test
- public void testHeatTreeCreation() {
+ public void testHeatTreeCreation() throws IOException {
FileContentHandler fileContentMap = new FileContentHandler();
URL url = this.getClass().getResource("/heatTreeValidationOutput");
@@ -59,7 +54,7 @@ public class HeatTreeManagerTest {
}
@Test
- public void testHeatTreeArtifactsCreated() {
+ public void testHeatTreeArtifactsCreated() throws IOException {
FileContentHandler fileContentMap = new FileContentHandler();
URL url = this.getClass().getResource("/heatTreeArtifactsValidationOutput");
@@ -88,23 +83,19 @@ public class HeatTreeManagerTest {
private void verifyHeatArtifacts(HeatStructureTree tree, String heatName, int expectedArtifactNum ) {
HeatStructureTree heat = HeatStructureTree.getHeatStructureTreeByName(tree.getHeat(), heatName);
- if(expectedArtifactNum > 0) {
+ Assert.assertNotNull(heat);
+ if (expectedArtifactNum > 0) {
Assert.assertNotNull(heat.getArtifacts());
Assert.assertEquals(heat.getArtifacts().size(), expectedArtifactNum);
} else {
Assert.assertNull(heat.getArtifacts());
}
-
}
- private byte[] getFileContent(File file) {
- try {
- return FileUtils.toByteArray(new FileInputStream(file));
- } catch (IOException e) {
- logger.debug("",e);
+ private byte[] getFileContent(File file) throws IOException {
+ try(InputStream inputStream = new FileInputStream(file)) {
+ return FileUtils.toByteArray(inputStream);
}
-
- return new byte[0];
}
}