Update the license for 2017-2018 license
[aai/traversal.git] / aai-traversal / src / test / java / org / onap / aai / transforms / MapTraverserTest.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 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 package org.onap.aai.transforms;
21
22 import org.onap.aai.transforms.LowerCamelToLowerHyphenConverter;
23 import org.onap.aai.transforms.MapTraverser;
24 import com.bazaarvoice.jolt.JsonUtils;
25 import org.junit.Test;
26
27 import java.io.IOException;
28 import java.util.Map;
29
30 public class MapTraverserTest {
31
32     private final String testResources = "src/test/resources/maputils/testcases/";
33
34     private String[] testCases = { "TestCase1.json", "TestCase2.json" };
35     private MapTraverser traverser = new MapTraverser(new LowerCamelToLowerHyphenConverter());
36
37     @Test(expected = NullPointerException.class)
38     public void testIfMapIsNullThrowNullPointerException(){
39         Map<String, Object> map = null;
40         traverser.convertKeys(map);
41     }
42
43     @Test
44     public void runTestCases() throws IOException {
45
46         for(String testCase : testCases){
47             Map<String, Object> values = JsonUtils.filepathToMap(testResources + testCase);
48
49             Object input = values.get("input");
50             Object actual = traverser.convertKeys((Map<String, Object>)input);
51             Object output = values.get("output");
52             JoltTestUtil.runArrayOrderObliviousDiffy( "failed case " + testCase, output, actual );
53         }
54     }
55 }