2 * ============LICENSE_START=======================================================
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
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=========================================================
20 package org.onap.aai.transforms;
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;
27 import java.io.IOException;
30 public class MapTraverserTest {
32 private final String testResources = "src/test/resources/maputils/testcases/";
34 private String[] testCases = { "TestCase1.json", "TestCase2.json" };
35 private MapTraverser traverser = new MapTraverser(new LowerCamelToLowerHyphenConverter());
37 @Test(expected = NullPointerException.class)
38 public void testIfMapIsNullThrowNullPointerException(){
39 Map<String, Object> map = null;
40 traverser.convertKeys(map);
44 public void runTestCases() throws IOException {
46 for(String testCase : testCases){
47 Map<String, Object> values = JsonUtils.filepathToMap(testResources + testCase);
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 );