2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020-2021 Nokia Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.validation.impl.validators;
23 import static org.junit.jupiter.api.Assertions.assertEquals;
24 import static org.junit.jupiter.api.Assertions.assertNotNull;
27 import org.junit.jupiter.api.Test;
28 import org.openecomp.core.validation.types.MessageContainer;
29 import org.openecomp.sdc.validation.util.ValidationTestUtil;
31 public class PmDictionaryValidatorTest {
33 private static final String RESOURCE_PATH = "/org/openecomp/validation/validators/pm_dictionary_validator";
34 private static final String VALID_PM_DICTIONARY_PACKAGE_PATH = "valid_file/";
35 private static final String INVALID_PM_DICTIONARY_PACKAGE_PATH = "invalid_file/";
36 private static final String WRONG_PM_DICTIONARY_TYPE_PACKAGE_PATH = "wrong_file_type/";
37 private static final String PM_DICTIONARY_FILE_NAME = "pmdict.yaml";
41 void shouldNotReturnErrorsWhenValidPmDict() {
43 Map<String, MessageContainer> messages = runValidation(
44 RESOURCE_PATH + "/" + VALID_PM_DICTIONARY_PACKAGE_PATH);
47 assertNotNull(messages);
48 assertEquals(0, messages.size());
52 void shouldReturnErrorsWhenInvalidPmDict() {
54 Map<String, MessageContainer> messages = runValidation(
55 RESOURCE_PATH + "/" + INVALID_PM_DICTIONARY_PACKAGE_PATH);
58 assertNotNull(messages);
59 assertNotNull(messages.get(PM_DICTIONARY_FILE_NAME));
60 assertEquals(4, messages.get(PM_DICTIONARY_FILE_NAME).getErrorMessageList().size());
64 void shouldNotReturnErrorsWhenInvalidPmDictButWrongPmDictionaryTypeInManifest() {
66 Map<String, MessageContainer> messages = runValidation(
67 RESOURCE_PATH + "/" + WRONG_PM_DICTIONARY_TYPE_PACKAGE_PATH);
70 assertNotNull(messages);
71 assertEquals(0, messages.size());
74 private Map<String, MessageContainer> runValidation(String path) {
75 PmDictionaryValidator validator = new PmDictionaryValidator();
76 return new ValidationTestUtil().testValidator(validator, path);