summaryrefslogtreecommitdiffstats
path: root/csarvalidation/src/test/java
diff options
context:
space:
mode:
authorjitendra007 <jitendra.sharma1@huawei.com>2020-07-30 14:57:18 +0530
committerjitendra007 <jitendra.sharma1@huawei.com>2020-08-05 14:54:53 +0530
commit4c059762652cd47c2f5a37deec36b3bdb2381782 (patch)
tree6c66c401b73392137b9d1390bb3dfe0a4c8ab28e /csarvalidation/src/test/java
parentbd519dbce7ea6444972e78658faa68fe6a8d84db (diff)
Fix sonar issues for validation
Issue-ID: VNFSDK-608 Signed-off-by: jitendra007 <jitendra.sharma1@huawei.com> Change-Id: Ib56d706444190d11958f125e666b0e0fbeab5391
Diffstat (limited to 'csarvalidation/src/test/java')
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/CSARArchiveTest.java4
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/PnfCSARArchiveTest.java40
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/PnfManifestParserTest.java49
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/PnfMetadataParserTest.java2
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/PnfNonManoArtifactsParserTest.java4
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/VnfManifestParserTest.java6
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR10087IntegrationTest.java13
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR130206IntegrationTest.java4
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092IntegrationTest.java4
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901IntegrationTest.java2
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR57019IntegrationTest.java2
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787965IntegrationTest.java4
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR816745IntegrationTest.java2
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR972082IntegrationTest.java4
-rw-r--r--csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/CsarValidatorTest.java101
-rw-r--r--csarvalidation/src/test/java/org/onap/validation/yaml/model/YamlDocumentFactoryTest.java4
16 files changed, 181 insertions, 64 deletions
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/CSARArchiveTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/CSARArchiveTest.java
index 2831532..3b18a1b 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/CSARArchiveTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/CSARArchiveTest.java
@@ -20,8 +20,9 @@ import java.io.IOException;
import java.util.Arrays;
import org.junit.Test;
-
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
public class CSARArchiveTest {
@Test
@@ -35,6 +36,7 @@ public class CSARArchiveTest {
csar.init("./src/test/resources/" + csarFileName + ".csar");
csar.parse();
csar.cleanup();
+ assertTrue(csar.getErrors().size() > 0);
System.out.println(csar.getErrors());
} catch (Exception e) {
// TODO Auto-generated catch block
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfCSARArchiveTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfCSARArchiveTest.java
index cf24e53..4f46b74 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfCSARArchiveTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfCSARArchiveTest.java
@@ -19,11 +19,11 @@ package org.onap.cvc.csar;
import com.google.common.collect.Lists;
import org.junit.Test;
import org.onap.cvc.csar.parser.SourcesParser;
-
import java.util.List;
import java.util.Map;
-
import static org.assertj.core.api.Assertions.assertThat;
+import java.util.Collections;
+import java.util.HashMap;
public class PnfCSARArchiveTest {
@@ -45,7 +45,7 @@ public class PnfCSARArchiveTest {
verifyThatCmsSectionWasSet(manifest);
verifyThatSourcesSectionWasSet(manifest);
verifyThatNonManoArtifactsWereSet(manifest);
- assertThat(pnfCSARArchive.getErrors().size()).isEqualTo(0);
+ assertThat(pnfCSARArchive.getErrors().size()).isZero();
}
}
@@ -76,23 +76,27 @@ public class PnfCSARArchiveTest {
private void verifyThatNonManoArtifactsWereSet(CSARArchive.Manifest manifest) {
Map<String, Map<String, List<String>>> nonManoArtifacts = manifest.getNonMano();
- assertThat(nonManoArtifacts.get("onap_ves_events").get(SOURCE_TAG))
- .isEqualTo(Lists.newArrayList("Artifacts/Events/VES_registration.yml")
- );
- assertThat(nonManoArtifacts.get("onap_pm_dictionary").get(SOURCE_TAG))
- .isEqualTo(Lists.newArrayList("Artifacts/Measurements/PM_Dictionary.yaml")
- );
- assertThat(nonManoArtifacts.get("onap_yang_modules").get(SOURCE_TAG))
- .isEqualTo(Lists.newArrayList("Artifacts/Yang_module/Yang_module.yaml")
- );
- assertThat(nonManoArtifacts.get("onap_others").get(SOURCE_TAG))
- .isEqualTo(Lists.newArrayList(
- "Artifacts/scripts/install.sh",
+ Map<String, List<String>>mapValue1=new HashMap<>();
+ Map<String, List<String>>mapValue2=new HashMap<>();
+ Map<String, List<String>>mapValue3=new HashMap<>();
+ Map<String, List<String>>mapValue4=new HashMap<>();
+
+ mapValue1.put("", Collections.singletonList(""));
+ mapValue1.put(SOURCE_TAG,Lists.newArrayList("Artifacts/Events/VES_registration.yml"));
+ mapValue2.put("", Collections.singletonList(""));
+ mapValue2.put(SOURCE_TAG,Lists.newArrayList("Artifacts/Measurements/PM_Dictionary.yaml"));
+ mapValue3.put("", Collections.singletonList(""));
+ mapValue3.put(SOURCE_TAG,Lists.newArrayList("Artifacts/Yang_module/Yang_module.yaml"));
+ mapValue4.put("", Collections.singletonList(""));
+ mapValue4.put(SOURCE_TAG,Lists.newArrayList
+ ("Artifacts/scripts/install.sh",
"Artifacts/Informational/user_guide.txt",
"Artifacts/Other/installation_guide.txt",
- "Artifacts/Other/review_log.txt"
- )
- );
+ "Artifacts/Other/review_log.txt"));
+ assertThat(nonManoArtifacts).containsEntry("onap_ves_events",mapValue1);
+ assertThat(nonManoArtifacts).containsEntry("onap_pm_dictionary",mapValue2);
+ assertThat(nonManoArtifacts).containsEntry("onap_yang_modules",mapValue3);
+ assertThat(nonManoArtifacts).containsEntry("onap_others",mapValue4);
}
} \ No newline at end of file
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfManifestParserTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfManifestParserTest.java
index a708f47..5749a73 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfManifestParserTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfManifestParserTest.java
@@ -25,6 +25,8 @@ import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
+import java.util.Collections;
+import java.util.HashMap;
import static org.assertj.core.api.Assertions.assertThat;
@@ -48,7 +50,7 @@ public class PnfManifestParserTest {
assertThat(metadata.getProviderId()).isEqualTo("Ericsson");
assertThat(metadata.getPackageVersion()).isEqualTo("1.0");
assertThat(metadata.getReleaseDateTime()).isEqualTo("2019-01-14T11:25:00+00:00");
- assertThat(errors.size()).isEqualTo(0);
+ assertThat(errors.size()).isZero();
}
@@ -64,7 +66,7 @@ public class PnfManifestParserTest {
new SourcesParser.Source("scripts/install.sh", "SHA-256", "d0e7828293355a07c2dccaaa765c80b507e60e6167067c950dc2e6b0da0dbd8b"),
new SourcesParser.Source("https://www.vendor_org.com/MRF/v4.1/scripts/scale/scale.sh", "SHA-256", "36f945953929812aca2701b114b068c71bd8c95ceb3609711428c26325649165")
);
- assertThat(errors.size()).isEqualTo(0);
+ assertThat(errors.size()).isZero();
}
@@ -81,7 +83,7 @@ public class PnfManifestParserTest {
new SourcesParser.Source("some_file.sh", "", ""),
new SourcesParser.Source("scripts/install.sh", "", "d0e7828293355a07c2dccaaa765c80b507e60e6167067c950dc2e6b0da0dbd8b"),
new SourcesParser.Source("https://www.vendor_org.com/MRF/v4.1/scripts/scale/scale.sh", "SHA-256", ""));
- assertThat(errors.size()).isEqualTo(0);
+ assertThat(errors.size()).isZero();
}
@@ -90,25 +92,28 @@ public class PnfManifestParserTest {
Pair<Map<String, Map<String, List<String>>>, List<CSARArchive.CSARError>> mapListPair = pnfManifestParser.fetchNonManoArtifacts().get();
Map<String, Map<String, List<String>>> nonManoArtifacts = mapListPair.getKey();
List<CSARArchive.CSARError> errors = mapListPair.getValue();
-
- assertThat(nonManoArtifacts.get("onap_ves_events").get("source"))
- .isEqualTo(Lists.newArrayList("Artifacts/Events/VES_registration.yml")
- );
- assertThat(nonManoArtifacts.get("onap_pm_dictionary").get("source"))
- .isEqualTo(Lists.newArrayList("Artifacts/Measurements/PM_Dictionary.yaml")
- );
- assertThat(nonManoArtifacts.get("onap_yang_module").get("source"))
- .isEqualTo(Lists.newArrayList("Artifacts/Yang_module/Yang_module.yaml")
- );
- assertThat(nonManoArtifacts.get("onap_others").get("source"))
- .isEqualTo(Lists.newArrayList(
- "Artifacts/scripts/install.sh",
+ Map<String, List<String>>mapValue1=new HashMap<>();
+ Map<String, List<String>>mapValue2=new HashMap<>();
+ Map<String, List<String>>mapValue3=new HashMap<>();
+ Map<String, List<String>>mapValue4=new HashMap<>();
+
+ mapValue1.put("", Collections.singletonList(""));
+ mapValue1.put("source",Lists.newArrayList("Artifacts/Events/VES_registration.yml"));
+ mapValue2.put("", Collections.singletonList(""));
+ mapValue2.put("source",Lists.newArrayList("Artifacts/Measurements/PM_Dictionary.yaml"));
+ mapValue3.put("", Collections.singletonList(""));
+ mapValue3.put("source",Lists.newArrayList("Artifacts/Yang_module/Yang_module.yaml"));
+ mapValue4.put("", Collections.singletonList(""));
+ mapValue4.put("source",Lists.newArrayList
+ ("Artifacts/scripts/install.sh",
"Artifacts/Informational/user_guide.txt",
"Artifacts/Other/installation_guide.txt",
- "Artifacts/Other/review_log.txt"
- )
- );
- assertThat(errors.size()).isEqualTo(0);
+ "Artifacts/Other/review_log.txt"));
+ assertThat(nonManoArtifacts).containsEntry("onap_ves_events",mapValue1);
+ assertThat(nonManoArtifacts).containsEntry("onap_pm_dictionary",mapValue2);
+ assertThat(nonManoArtifacts).containsEntry("onap_yang_module",mapValue3);
+ assertThat(nonManoArtifacts).containsEntry("onap_others",mapValue4);
+ assertThat(errors.size()).isZero();
}
@@ -154,7 +159,7 @@ public class PnfManifestParserTest {
"HhE7UbSCHDlDDgrOosJkbuI4UCX/njXrU2ukXbrWz/FjH84Mek039z+w4M6fBnl5"+
"4xuyO1o65LlKHoxwnRH9lQ=="
);
- assertThat(errors.size()).isEqualTo(0);
+ assertThat(errors.size()).isZero();
}
@Test
@@ -214,6 +219,6 @@ public class PnfManifestParserTest {
new SourcesParser.Source("Artifacts/Other/review_log.txt", "SHA-256", "36f945953929812aca2701b114b068c71bd8c95ceb3609711428c26325649165")
);
- assertThat(errors.size()).isEqualTo(0);
+ assertThat(errors.size()).isZero();
}
}
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfMetadataParserTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfMetadataParserTest.java
index c409efc..4a08a5d 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfMetadataParserTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfMetadataParserTest.java
@@ -122,7 +122,7 @@ public class PnfMetadataParserTest {
//then
List<CSARArchive.CSARError> errors = data.getRight();
- assertThat(errors.size()).isEqualTo(0);
+ assertThat(errors.size()).isZero();
}
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfNonManoArtifactsParserTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfNonManoArtifactsParserTest.java
index 388a98f..2cd648a 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfNonManoArtifactsParserTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfNonManoArtifactsParserTest.java
@@ -56,7 +56,7 @@ public class PnfNonManoArtifactsParserTest {
pnfManifestParser.fetchNonManoArtifacts();
//then
- assertThat(nonManoArtifacts.isPresent()).isFalse();
+ assertThat(nonManoArtifacts).isNotPresent();
}
@Test
@@ -88,7 +88,7 @@ public class PnfNonManoArtifactsParserTest {
//then
List<CSARArchive.CSARError> errors = data.getRight();
- assertThat(errors.size()).isEqualTo(0);
+ assertThat(errors.size()).isZero();
}
}
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/VnfManifestParserTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/VnfManifestParserTest.java
index 91bb6b1..7fa73a7 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/VnfManifestParserTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/VnfManifestParserTest.java
@@ -43,7 +43,7 @@ public class VnfManifestParserTest {
CSARArchive.Manifest.Metadata metadata = metadataListPair.getKey();
List<CSARArchive.CSARError> errors = metadataListPair.getValue();
- assertThat(errors.size()).isEqualTo(0);
+ assertThat(errors.size()).isZero();
assertThat(metadata.getProductName()).isEqualTo(" vCSCF");
assertThat(metadata.getProviderId()).isEqualTo(" ZTE");
assertThat(metadata.getPackageVersion()).isEqualTo(" 1.0");
@@ -64,7 +64,7 @@ public class VnfManifestParserTest {
new SourcesParser.Source("scripts/install.sh", "SHA-256", "d0e7828293355a07c2dccaaa765c80b507e60e6167067c950dc2e6b0da0dbd8b"),
new SourcesParser.Source("https://www.vendor_org.com/MRF/v4.1/scripts/scale/scale.sh", "SHA-256", "36f945953929812aca2701b114b068c71bd8c95ceb3609711428c26325649165")
);
- assertThat(errors.size()).isEqualTo(0);
+ assertThat(errors.size()).isZero();
}
@Test
@@ -79,6 +79,6 @@ public class VnfManifestParserTest {
"AQcBoFEET3icc87PK0nNK9ENqSxItVIoSa0o0S/ISczMs1ZIzkgsKk4tsQ0N1nUM" +
"dvb05OXi5XLPLEtViMwvLVLwSE0sKlFIVHAqSk3MBkkBAJv0Fx0="
);
- assertThat(errors.size()).isEqualTo(0);
+ assertThat(errors.size()).isZero();
}
}
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR10087IntegrationTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR10087IntegrationTest.java
index 921e903..2cc739c 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR10087IntegrationTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR10087IntegrationTest.java
@@ -63,6 +63,19 @@ public class VTPValidateCSARR10087IntegrationTest {
}
@Test
+ public void testWithoutTOSCAMetaDir() throws Exception {
+ // given
+ configureTestCase(testCase, "pnf/toscaMetaFile.csar", "vtp-validate-csar-r10087.yaml", IS_PNF);
+
+ // when
+ testCase.execute();
+
+ // then
+ List<CSARArchive.CSARError> errors = testCase.getErrors();
+ assertThat(errors.size()).isEqualTo(7);
+ }
+
+ @Test
public void shouldReportThatDefinitionYAMLDoesNotExist() throws Exception {
// given
configureTestCase(testCase, "pnf/r10087/invalidEntryDefinitionsInToscaMeta.csar", "vtp-validate-csar-r10087.yaml", IS_PNF);
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR130206IntegrationTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR130206IntegrationTest.java
index eef9881..3eed6c6 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR130206IntegrationTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR130206IntegrationTest.java
@@ -59,7 +59,7 @@ public class VTPValidateCSARR130206IntegrationTest {
// then
List<CSARArchive.CSARError> errors = testCase.getErrors();
- assertThat(errors.size()).isEqualTo(0);
+ assertThat(errors.size()).isZero();
}
@Test
@@ -77,7 +77,7 @@ public class VTPValidateCSARR130206IntegrationTest {
// then
List<CSARArchive.CSARError> errors = testCase.getErrors();
- assertThat(errors.size()).isEqualTo(0);
+ assertThat(errors.size()).isZero();
}
@Test
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092IntegrationTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092IntegrationTest.java
index d2a7b8a..a10aa91 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092IntegrationTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR146092IntegrationTest.java
@@ -54,7 +54,7 @@ public class VTPValidateCSARR146092IntegrationTest {
// then
final List<CSARError> errors = testCase.getErrors();
- assertThat(errors.size()).isEqualTo(0);
+ assertThat(errors.size()).isZero();
}
@Test
@@ -68,7 +68,7 @@ public class VTPValidateCSARR146092IntegrationTest {
// then
final List<CSARError> errors = testCase.getErrors();
- assertThat(errors.size()).isEqualTo(0);
+ assertThat(errors.size()).isZero();
}
@Test
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901IntegrationTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901IntegrationTest.java
index 2835772..2b9b4f4 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901IntegrationTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR293901IntegrationTest.java
@@ -71,7 +71,7 @@ public class VTPValidateCSARR293901IntegrationTest {
// then
List<CSARArchive.CSARError> errors = testCase.getErrors();
- assertThat(errors.size()).isEqualTo(0);
+ assertThat(errors.size()).isZero();
}
@Test
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR57019IntegrationTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR57019IntegrationTest.java
index 088eab7..d6d06b3 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR57019IntegrationTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR57019IntegrationTest.java
@@ -73,7 +73,7 @@ public class VTPValidateCSARR57019IntegrationTest {
// then
List<CSARArchive.CSARError> errors = testCase.getErrors();
- assertThat(errors.size()).isEqualTo(0);
+ assertThat(errors.size()).isZero();
}
@Test
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787965IntegrationTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787965IntegrationTest.java
index 49696e6..33a1754 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787965IntegrationTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787965IntegrationTest.java
@@ -76,7 +76,7 @@ public class VTPValidateCSARR787965IntegrationTest {
// then
List<CSARArchive.CSARError> errors = testCase.getErrors();
- assertThat(errors.size()).isEqualTo(0);
+ assertThat(errors.size()).isZero();
}
@Test
@@ -111,7 +111,7 @@ public class VTPValidateCSARR787965IntegrationTest {
// then
List<CSARArchive.CSARError> errors = testCase.getErrors();
- assertThat(errors.size()).isEqualTo(0);
+ assertThat(errors.size()).isZero();
}
}
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR816745IntegrationTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR816745IntegrationTest.java
index 5ef4e99..ac8f964 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR816745IntegrationTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR816745IntegrationTest.java
@@ -60,7 +60,7 @@ public class VTPValidateCSARR816745IntegrationTest {
// then
List<CSARArchive.CSARError> errors = testCase.getErrors();
- assertThat(errors.size()).isEqualTo(0);
+ assertThat(errors.size()).isZero();
}
@Test
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR972082IntegrationTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR972082IntegrationTest.java
index b63705b..868fad2 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR972082IntegrationTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR972082IntegrationTest.java
@@ -57,7 +57,7 @@ public class VTPValidateCSARR972082IntegrationTest {
// then
final List<CSARError> errors = testCase.getErrors();
- assertThat(errors.size()).isEqualTo(0);
+ assertThat(errors.size()).isZero();
}
@Test
@@ -87,7 +87,7 @@ public class VTPValidateCSARR972082IntegrationTest {
// then
final List<CSARError> errors = testCase.getErrors();
- assertThat(errors.size()).isEqualTo(0);
+ assertThat(errors.size()).isZero();
}
@Test
diff --git a/csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/CsarValidatorTest.java b/csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/CsarValidatorTest.java
index f9a8d8a..c2856d9 100644
--- a/csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/CsarValidatorTest.java
+++ b/csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/CsarValidatorTest.java
@@ -21,7 +21,6 @@ import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -35,7 +34,15 @@ import org.junit.Test;
import org.onap.validation.csar.CommonConstants;
import org.onap.validation.csar.CsarValidator;
import org.onap.validation.csar.FileUtil;
-
+import org.onap.validation.csar.ValidationException;
+import org.junit.runner.RunWith;
+import mockit.integration.junit4.JMockit;
+import mockit.Expectations;
+import mockit.Mocked;
+import mockit.Mock;
+import mockit.MockUp;
+
+@RunWith(JMockit.class)
public class CsarValidatorTest {
String regex = "^\\/[a-zA-Z]\\:\\/";
@@ -162,6 +169,18 @@ public class CsarValidatorTest {
assertTrue(true);
}
+ @Test(expected = ValidationException.class)
+ public void testCloseInputStream2( @Mocked InputStream inputStream) throws IOException {
+ new Expectations(){
+ {
+ inputStream.close();
+ result = new IOException();
+ }
+ };
+ FileUtil.closeInputStream(inputStream);
+ assertTrue(true);
+ }
+
@Test
public void testCloseZipFile() throws ZipException, IOException {
File file = new File(sample1);
@@ -170,10 +189,23 @@ public class CsarValidatorTest {
assertTrue(true);
}
- @Test
- public void testCloseFileStream() throws FileNotFoundException {
+ @Test(expected = IOException.class)
+ public void testCloseFileStream() throws IOException {
FileInputStream dir3 = new FileInputStream(sample1);
FileUtil.closeFileStream(dir3);
+ dir3.available();
+
+ }
+
+ @Test(expected = ValidationException.class)
+ public void testCloseFileStream2(@Mocked FileInputStream fileInputStream) throws IOException {
+ new Expectations(){
+ {
+ fileInputStream.close();
+ result = new IOException();
+ }
+ };
+ FileUtil.closeFileStream(fileInputStream);
}
@Test
@@ -186,6 +218,18 @@ public class CsarValidatorTest {
}
};
FileUtil.closeOutputStream(dir4);
+ assertTrue(true);
+ }
+
+ @Test(expected = ValidationException.class)
+ public void testCloseOutptutStream2(@Mocked OutputStream outputStream) throws IOException {
+ new Expectations(){
+ {
+ outputStream.close();
+ result = new IOException();
+ }
+ };
+ FileUtil.closeOutputStream(outputStream);
}
private void testValidateCsarMeta(CsarValidator cv) {
@@ -219,4 +263,53 @@ public class CsarValidatorTest {
String result = CsarValidator.r02454();
assertEquals(true, result == CommonConstants.SUCCESS_STR);
}
+
+ @Test
+ public void testValidateCsar() throws IOException {
+ new MockUp<CsarValidator>(){
+ @Mock
+ public String validateCsarMeta(){
+ return "FAIL";
+ }
+ @Mock
+ public String validateAndScanToscaMeta(){
+ return "SUCCESS";
+ }
+ @Mock
+ public String validateMainService(){
+ return "FAIL";
+ }
+ };
+ String res=CsarValidator.validateCsar();
+ assertEquals("FAIL OR FAIL",res);
+
+ }
+
+ @Test
+ public void testValidateCsar2() throws IOException {
+ new MockUp<CsarValidator>(){
+ @Mock
+ public String validateCsarMeta(){
+ return "SUCCESS";
+ }
+ @Mock
+ public String validateAndScanToscaMeta(){
+ return "FAIL";
+ }
+ @Mock
+ public String validateMainService(){
+ return "SUCCESS";
+ }
+ };
+ String res=CsarValidator.validateCsar();
+ assertEquals("FAIL",res);
+ }
+
+ @Test
+ public void testDeleteDir(){
+ String dstPath = "./dstPathForTest1";
+ File dst = new File(dstPath);
+ dst.mkdir();
+ assertTrue(FileUtil.deleteFile(dstPath));
+ }
}
diff --git a/csarvalidation/src/test/java/org/onap/validation/yaml/model/YamlDocumentFactoryTest.java b/csarvalidation/src/test/java/org/onap/validation/yaml/model/YamlDocumentFactoryTest.java
index 5641a56..7879d4e 100644
--- a/csarvalidation/src/test/java/org/onap/validation/yaml/model/YamlDocumentFactoryTest.java
+++ b/csarvalidation/src/test/java/org/onap/validation/yaml/model/YamlDocumentFactoryTest.java
@@ -52,13 +52,13 @@ public class YamlDocumentFactoryTest {
assertThat(document).isNotNull();
assertThat(document.getYaml()).containsKeys("test", "345", "test2", "2.67");
- assertThat(document.getYaml().get("test")).isEqualTo(testList);
+ assertThat(document.getYaml()).containsEntry("test", testList);
assertThat(document.getValue("test")).isEqualTo("[element1, element11]");
assertThat(document.getValue("345")).isEqualTo("element2");
assertThat(document.getValue("test2")).isEqualTo("element3");
- assertThat(document.getYaml().get("2.67")).isEqualTo(testEmptyMap);
+ assertThat(document.getYaml()).containsEntry("2.67", testEmptyMap);
assertThat(document.getValue("2.67")).isEqualTo("{}");
}