2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 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_YAML = "valid_pm_dictionary.yaml";
35 private static final String INVALID_PM_DICTIONARY_YAML = "invalid_pm_dictionary.yaml";
38 public void shouldNotReturnErrorsWhenValidPmDict() {
39 Map<String, MessageContainer> messages = runValidation(
40 RESOURCE_PATH + "/" + VALID_PM_DICTIONARY_YAML);
42 assertNotNull(messages);
43 assertEquals(0, messages.size());
47 public void shouldReturnErrorsWhenInvalidPmDict() {
48 Map<String, MessageContainer> messages = runValidation(
49 RESOURCE_PATH + "/" + INVALID_PM_DICTIONARY_YAML);
51 assertNotNull(messages);
52 assertNotNull(messages.get(INVALID_PM_DICTIONARY_YAML));
53 assertEquals(4, messages.get(INVALID_PM_DICTIONARY_YAML).getErrorMessageList().size());
56 private Map<String, MessageContainer> runValidation(String path) {
57 PmDictionaryValidator validator = new PmDictionaryValidator();
58 return ValidationTestUtil.testValidator(validator, path);