diff options
author | Adam Wudzinski <adam.wudzinski@nokia.com> | 2021-01-15 17:38:30 +0100 |
---|---|---|
committer | Adam Wudzinski <adam.wudzinski@nokia.com> | 2021-01-18 16:58:27 +0100 |
commit | f3b0ef4dc7cc21b273ea160781b5170b2d105e1a (patch) | |
tree | 04550aed49f28b599d2702a519ad7d51a855aac8 /openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java | |
parent | bd5a1006210092f9ac5c48352cc94f6264e961ef (diff) |
Map VSP PM_DICTIONARY Type to VF PM_DICTIONARY Type
File defined in ZIP VSP package as PM_DICTIONARY will be now mapped to PM_DICTIONARY type in VF. Also PmDictionaryValidator is run on files with PM_DICTIONARY type in ZIP Manifest file, instead of file naming convention.
Issue-ID: SDC-3390
Signed-off-by: Adam Wudzinski <adam.wudzinski@nokia.com>
Change-Id: I2e21353b9e80b6bb68c4c6d408ad1ffa33314e7b
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java')
3 files changed, 75 insertions, 43 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/FileExtensionUtilsTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/FileExtensionUtilsTest.java index 53a2cfa650..73b3112339 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/FileExtensionUtilsTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/FileExtensionUtilsTest.java @@ -39,22 +39,6 @@ class FileExtensionUtilsTest { ".properties" ); - private static final Set<String> VALID_PM_DICTIONARY_EXTENSIONS = Set.of( - "pmdict.yml", - "pmdict.yaml", - "pm_dict.yml", - "pm_dict.yaml", - "pmdictionary.yml", - "pmdictionary.yaml", - "pm_dictionary.yml", - "pm_dictionary.yaml" - ); - private static final Set<String> INVALID_PM_DICTIONARY_EXTENSIONS = Set.of( - "pmdict.txt", - "pmdict.java", - "pm.yml" - ); - private static final Set<String> TEST_FILE_PREFIXES = Set.of( "test", "test_file" @@ -76,22 +60,6 @@ class FileExtensionUtilsTest { assertTrue(allInvalidFilesNotMatched); } - @Test - void shouldMatchProperPmDictionaryExtensions() { - final boolean allValidFilesMatched = constructTestFilenamesWithExtensions(VALID_PM_DICTIONARY_EXTENSIONS) - .allMatch(FileExtensionUtils::isPmDictionary); - - assertTrue(allValidFilesMatched); - } - - @Test - void shouldNotMatchImproperPmDictionaryExtensions() { - final boolean allInvalidFilesNotMatched = constructTestFilenamesWithExtensions(INVALID_PM_DICTIONARY_EXTENSIONS) - .noneMatch(FileExtensionUtils::isPmDictionary); - - assertTrue(allInvalidFilesNotMatched); - } - private Stream<String> constructTestFilenamesWithExtensions(Set<String> extensions) { return extensions.stream() .flatMap(ext -> prepareFilenamesWithExtension(ext).stream()); @@ -108,4 +76,4 @@ class FileExtensionUtilsTest { return TEST_FILE_PREFIXES.stream() .map(prefix -> prefix + extension); } -}
\ No newline at end of file +} diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/GlobalContextUtilTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/GlobalContextUtilTest.java new file mode 100644 index 0000000000..5856b3f322 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/GlobalContextUtilTest.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2021 Nokia Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.validation.impl.validators; + +import org.junit.jupiter.api.Test; +import org.openecomp.core.validation.types.GlobalValidationContext; +import org.openecomp.sdc.validation.util.ValidationTestUtil; + +import java.util.Set; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class GlobalContextUtilTest { + private static final String TEST_MANIFEST_PATH = "/org/openecomp/validation/validators/global_context_util/"; + + @Test + void shouldReturnOnlyFilesWithPmDictionaryType() { + // given + GlobalValidationContext globalContext = ValidationTestUtil.createGlobalContextFromPath(TEST_MANIFEST_PATH); + + // when + Set<String> pmDictionaryFiles = GlobalContextUtil.findPmDictionaryFiles(globalContext); + + // then + assertEquals(1, pmDictionaryFiles.size()); + } + +} diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/PmDictionaryValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/PmDictionaryValidatorTest.java index d841694a23..b510eeb26a 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/PmDictionaryValidatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/PmDictionaryValidatorTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * SDC * ================================================================================ - * Copyright (C) 2020 Nokia Intellectual Property. All rights reserved. + * Copyright (C) 2020-2021 Nokia Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,30 +31,48 @@ import org.openecomp.sdc.validation.util.ValidationTestUtil; public class PmDictionaryValidatorTest { private static final String RESOURCE_PATH = "/org/openecomp/validation/validators/pm_dictionary_validator"; - private static final String VALID_PM_DICTIONARY_YAML = "valid_pm_dictionary.yaml"; - private static final String INVALID_PM_DICTIONARY_YAML = "invalid_pm_dictionary.yaml"; + private static final String VALID_PM_DICTIONARY_PACKAGE_PATH = "valid_file/"; + private static final String INVALID_PM_DICTIONARY_PACKAGE_PATH = "invalid_file/"; + private static final String WRONG_PM_DICTIONARY_TYPE_PACKAGE_PATH = "wrong_file_type/"; + private static final String PM_DICTIONARY_FILE_NAME = "pmdict.yaml"; + @Test - public void shouldNotReturnErrorsWhenValidPmDict() { + void shouldNotReturnErrorsWhenValidPmDict() { + // when Map<String, MessageContainer> messages = runValidation( - RESOURCE_PATH + "/" + VALID_PM_DICTIONARY_YAML); + RESOURCE_PATH + "/" + VALID_PM_DICTIONARY_PACKAGE_PATH); + // then assertNotNull(messages); assertEquals(0, messages.size()); } @Test - public void shouldReturnErrorsWhenInvalidPmDict() { + void shouldReturnErrorsWhenInvalidPmDict() { + // when + Map<String, MessageContainer> messages = runValidation( + RESOURCE_PATH + "/" + INVALID_PM_DICTIONARY_PACKAGE_PATH); + + // then + assertNotNull(messages); + assertNotNull(messages.get(PM_DICTIONARY_FILE_NAME)); + assertEquals(4, messages.get(PM_DICTIONARY_FILE_NAME).getErrorMessageList().size()); + } + + @Test + void shouldNotReturnErrorsWhenInvalidPmDictButWrongPmDictionaryTypeInManifest() { + // when Map<String, MessageContainer> messages = runValidation( - RESOURCE_PATH + "/" + INVALID_PM_DICTIONARY_YAML); + RESOURCE_PATH + "/" + WRONG_PM_DICTIONARY_TYPE_PACKAGE_PATH); + // then assertNotNull(messages); - assertNotNull(messages.get(INVALID_PM_DICTIONARY_YAML)); - assertEquals(4, messages.get(INVALID_PM_DICTIONARY_YAML).getErrorMessageList().size()); + assertEquals(0, messages.size()); } private Map<String, MessageContainer> runValidation(String path) { PmDictionaryValidator validator = new PmDictionaryValidator(); return ValidationTestUtil.testValidator(validator, path); } -}
\ No newline at end of file +} |