summaryrefslogtreecommitdiffstats
path: root/csarvalidation/src/test/java/org/onap/cvc
diff options
context:
space:
mode:
authorBartosz Gardziejewski <bartosz.gardziejewski@nokia.com>2020-08-18 13:31:29 +0200
committerBartosz Gardziejewski <bartosz.gardziejewski@nokia.com>2020-08-20 07:15:03 +0200
commit7be0ab69d0828950c1601566ae9857a104e7124d (patch)
treefaf4e99b60317ccc1d22c08f35ee72998e776d16 /csarvalidation/src/test/java/org/onap/cvc
parente937fd80bf7b33e1dc900dd0ecce6dfcddaacf7d (diff)
Wrap exceptions connected with Yaml parsing in order to send them as validation error.
Signed-off-by: Bartosz Gardziejewski <bartosz.gardziejewski@nokia.com> Change-Id: Iae6c0948746bb903945de1796b6f42952d4072ba Issue-ID: VNFSDK-644
Diffstat (limited to 'csarvalidation/src/test/java/org/onap/cvc')
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR816745IntegrationTest.java34
1 files changed, 34 insertions, 0 deletions
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 ac8f964..f171b4d 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
@@ -39,6 +39,7 @@ public class VTPValidateCSARR816745IntegrationTest {
private static final boolean IS_PNF = true;
private static final String TEST_CSAR_DIRECTORY = "pnf/r816745/";
private static final int NUMBER_OF_EXPECTED_ERRORS = 4;
+ private static final String LETTER_S_WITH_ASCII_CODE = "s(115)";
private VTPValidateCSARR816745 testCase;
@@ -128,6 +129,39 @@ public class VTPValidateCSARR816745IntegrationTest {
}
@Test
+ public void shouldReturnListContainingOneErrorsWhenCsarContainsPmDictionaryWithInvalidKeyMapping() throws Exception {
+ // given
+ configureTestCase(testCase, TEST_CSAR_DIRECTORY + "csar-with-invalid-pm-dictionary-invalid-mapping.csar", "vtp-validate-csar-r816745.yaml", IS_PNF);
+
+ // when
+ testCase.execute();
+
+ // then
+ List<CSARArchive.CSARError> errors = testCase.getErrors();
+ assertThat(errors.size()).isEqualTo(1);
+ assertThat(convertToMessagesList(errors).get(0)).contains(
+ "Fail to load PM_Dictionary With error: mapping values are not allowed here"
+ );
+ }
+
+ @Test
+ public void shouldReturnListContainingOneErrorsWhenCsarContainsPmDictionaryWithIncorrectEscapeCharacter() throws Exception {
+ // given
+ configureTestCase(testCase, TEST_CSAR_DIRECTORY + "csar-with-invalid-pm-dictionary-unknown-escape-character.csar", "vtp-validate-csar-r816745.yaml", IS_PNF);
+
+ // when
+ testCase.execute();
+
+ // then
+ List<CSARArchive.CSARError> errors = testCase.getErrors();
+ assertThat(errors.size()).isEqualTo(1);
+ assertThat(convertToMessagesList(errors).get(0)).contains(
+ "Fail to load PM_Dictionary With error: while scanning a double-quoted scalar",
+ "found unknown escape character " + LETTER_S_WITH_ASCII_CODE
+ );
+ }
+
+ @Test
public void shouldReturnProperRequestNumber() {
assertThat(testCase.getVnfReqsNo()).isEqualTo("R816745");
}