2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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.openecomp.aai.transforms;
23 import org.openecomp.aai.transforms.LowerCamelToLowerHyphenConverter;
24 import org.openecomp.aai.transforms.MapTraverser;
25 import com.bazaarvoice.jolt.JsonUtils;
26 import org.junit.Test;
28 import java.io.IOException;
31 public class MapTraverserTest {
33 private final String testResources = "src/test/resources/maputils/testcases/";
35 private String[] testCases = { "TestCase1.json", "TestCase2.json" };
36 private MapTraverser traverser = new MapTraverser(new LowerCamelToLowerHyphenConverter());
38 @Test(expected = NullPointerException.class)
39 public void testIfMapIsNullThrowNullPointerException(){
40 Map<String, Object> map = null;
41 traverser.convertKeys(map);
45 public void runTestCases() throws IOException {
47 for(String testCase : testCases){
48 Map<String, Object> values = JsonUtils.filepathToMap(testResources + testCase);
50 Object input = values.get("input");
51 Object actual = traverser.convertKeys((Map<String, Object>)input);
52 Object output = values.get("output");
53 JoltTestUtil.runArrayOrderObliviousDiffy( "failed case " + testCase, output, actual );