AAI-1523 checkstyle warnings for aai-schema-ingest
[aai/aai-common.git] / aai-schema-ingest / src / test / java / org / onap / aai / validation / edges / CousinDefaultingValidationModuleTest.java
1 /** 
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
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
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.onap.aai.validation.edges;
22
23 import static org.junit.Assert.*;
24
25 import java.util.ArrayList;
26 import java.util.HashMap;
27 import java.util.List;
28 import java.util.Map;
29
30 import org.junit.BeforeClass;
31 import org.junit.Test;
32 import org.onap.aai.edges.JsonIngestor;
33 import org.onap.aai.setup.SchemaVersion;
34
35 import com.jayway.jsonpath.DocumentContext;
36
37 public class CousinDefaultingValidationModuleTest {
38     private static List<DocumentContext> ctxs;
39     private static CousinDefaultingValidationModule validator;
40
41     @BeforeClass
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");
46
47         SchemaVersion LATEST_VERSION = new SchemaVersion("v14");
48         testRules.put(LATEST_VERSION, testFiles);
49         
50         JsonIngestor ji = new JsonIngestor();
51         ctxs = ji.ingest(testRules).get(LATEST_VERSION);
52         validator = new CousinDefaultingValidationModule();
53     }
54     
55     @Test
56     public void testValidCousins() {
57         assertTrue("".equals(validator.validate("boop|beep", ctxs)));
58     }
59
60     @Test
61     public void testValidBoth() {
62         assertTrue("".equals(validator.validate("monster|human", ctxs)));
63     }
64
65     @Test
66     public void testValidSingleContains() {
67         assertTrue("".equals(validator.validate("family|baby", ctxs)));
68     }
69     
70     @Test
71     public void testInvalidTooManyDefaults() {
72         assertTrue(validator.validate("sheep|wool", ctxs).contains("Multiple set"));
73     }
74     
75     @Test
76     public void testInvalidNoDefaults() {
77         assertTrue(validator.validate("cloth|thread", ctxs).contains("None set"));
78     }
79 }