2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-18 AT&T 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.onap.aai.validation.edges;
23 import static org.junit.Assert.*;
25 import java.util.ArrayList;
26 import java.util.HashMap;
27 import java.util.List;
30 import org.junit.BeforeClass;
31 import org.junit.Test;
32 import org.onap.aai.edges.JsonIngestor;
33 import org.onap.aai.setup.SchemaVersion;
35 import com.jayway.jsonpath.DocumentContext;
37 public class CousinDefaultingValidationModuleTest {
38 private static List<DocumentContext> ctxs;
39 private static CousinDefaultingValidationModule validator;
42 public static void setUpBeforeClass() {
43 Map<SchemaVersion, List<String>> testRules = new HashMap<>();
44 List<String> testFiles = new ArrayList<>();
45 testFiles.add("src/test/resources/edgeRules/cousinDefaultValidationTest.json");
47 SchemaVersion LATEST_VERSION = new SchemaVersion("v14");
48 testRules.put(LATEST_VERSION, testFiles);
50 JsonIngestor ji = new JsonIngestor();
51 ctxs = ji.ingest(testRules).get(LATEST_VERSION);
52 validator = new CousinDefaultingValidationModule();
56 public void testValidCousins() {
57 assertTrue("".equals(validator.validate("boop|beep", ctxs)));
61 public void testValidBoth() {
62 assertTrue("".equals(validator.validate("monster|human", ctxs)));
66 public void testValidSingleContains() {
67 assertTrue("".equals(validator.validate("family|baby", ctxs)));
71 public void testInvalidTooManyDefaults() {
72 assertTrue(validator.validate("sheep|wool", ctxs).contains("Multiple set"));
76 public void testInvalidNoDefaults() {
77 assertTrue(validator.validate("cloth|thread", ctxs).contains("None set"));