From 0499f0cd3522202708c926754e45a6d5e9c3c080 Mon Sep 17 00:00:00 2001 From: "andre.schmid" Date: Mon, 23 Aug 2021 11:59:28 +0100 Subject: Define a CSAR validator API for models Change-Id: Ibdbedcc7cfe3660221f35667902f2e4eadc19725 Issue-ID: SDC-3682 Signed-off-by: andre.schmid --- .../pmdictionary/CsarValidationTest.java | 36 ++++++++++++---------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'integration-tests/src/test/java/org/onap') diff --git a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/validation/pmdictionary/CsarValidationTest.java b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/validation/pmdictionary/CsarValidationTest.java index 2390de4780..9500c9b378 100644 --- a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/validation/pmdictionary/CsarValidationTest.java +++ b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/validation/pmdictionary/CsarValidationTest.java @@ -20,21 +20,24 @@ */ package org.onap.sdc.backend.ci.tests.validation.pmdictionary; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; + +import java.io.IOException; +import java.util.List; +import java.util.stream.Collectors; import org.junit.jupiter.api.Test; import org.openecomp.core.utilities.file.FileContentHandler; import org.openecomp.sdc.datatypes.error.ErrorLevel; import org.openecomp.sdc.datatypes.error.ErrorMessage; import org.openecomp.sdc.vendorsoftwareproduct.exception.OnboardPackageException; +import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.ValidationResult; import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.ValidatorFactory; -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; - class CsarValidationTest { @Test @@ -43,10 +46,10 @@ class CsarValidationTest { FileContentHandler pnfFileContent = CsarLoader.load("validPnfCompliantWithSOL004.csar", "/Files/PNFs/validation/pmdictionary/validPnfCompliantWithSOL004.csar"); //when - Map> errorsMap = ValidatorFactory.getValidator(pnfFileContent).validateContent(pnfFileContent); + final ValidationResult validationResult = ValidatorFactory.getValidator(pnfFileContent).validate(pnfFileContent); //then - assertThat(errorsMap, is(anEmptyMap())); + assertThat(validationResult.getErrors(), is(empty())); } @Test @@ -56,8 +59,8 @@ class CsarValidationTest { FileContentHandler pnfFileContent = CsarLoader.load("invalidPnfCompliantWithSOL004.csar", "/Files/PNFs/validation/pmdictionary/invalidPnfCompliantWithSOL004.csar"); //when - Map> errorMap = ValidatorFactory.getValidator(pnfFileContent).validateContent(pnfFileContent); - List errorList = errorMap.get("uploadFile"); + final ValidationResult validationResult = ValidatorFactory.getValidator(pnfFileContent).validate(pnfFileContent); + List errorList = validationResult.getErrors(); //then assertThat(errorList, is(not(empty()))); @@ -74,10 +77,11 @@ class CsarValidationTest { ); //when - Map> errorsMap = ValidatorFactory.getValidator(pnfFileContent).validateContent(pnfFileContent); + final ValidationResult validationResult = ValidatorFactory.getValidator(pnfFileContent).validate(pnfFileContent); //then - assertThat(errorsMap, is(anEmptyMap())); + assertThat(validationResult.isValid(), is(true)); + assertThat(validationResult.getErrors(), is(empty())); } @Test @@ -90,8 +94,8 @@ class CsarValidationTest { ); //when - Map> errorsMap = ValidatorFactory.getValidator(pnfFileContent).validateContent(pnfFileContent); - List errorList = errorsMap.get("uploadFile"); + final ValidationResult validationResult = ValidatorFactory.getValidator(pnfFileContent).validate(pnfFileContent); + List errorList = validationResult.getErrors(); //then assertThat(getActualErrorMessages(errorList), containsInAnyOrder(expectedErrorMessage.toArray())); -- cgit 1.2.3-korg