Changes for checkstyle 8.32
[policy/apex-pdp.git] / model / utilities / src / test / java / org / onap / policy / apex / model / utilities / TreeMapUtilsTest.java
1 /*
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  * 
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  * 
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  * 
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.apex.model.utilities;
22
23 import static org.junit.Assert.assertEquals;
24
25 import java.util.List;
26 import java.util.Map.Entry;
27 import java.util.TreeMap;
28 import org.junit.Test;
29
30 /**
31  * Test the tree map utilities.
32  * @author Liam Fallon (liam.fallon@ericsson.com)
33  */
34 public class TreeMapUtilsTest {
35
36     @Test
37     public void test() {
38         TreeMap<String, String> testTreeMap = new TreeMap<String, String>();
39         testTreeMap.put("G", "G");
40         testTreeMap.put("H", "H");
41         testTreeMap.put("JA", "JA");
42         testTreeMap.put("JAM", "JAM");
43         testTreeMap.put("JOE", "JOE");
44         testTreeMap.put("JOSH", "JOSH");
45         testTreeMap.put("K", "K");
46         
47         List<Entry<String, String>> foundKeyList = TreeMapUtils.findMatchingEntries(testTreeMap, "F");
48         assertEquals(0, foundKeyList.size());
49
50         foundKeyList = TreeMapUtils.findMatchingEntries(testTreeMap, "G");
51         assertEquals("G", foundKeyList.get(0).getKey());
52
53         foundKeyList = TreeMapUtils.findMatchingEntries(testTreeMap, "H");
54         assertEquals("H", foundKeyList.get(0).getKey());
55  
56         foundKeyList = TreeMapUtils.findMatchingEntries(testTreeMap, "I");
57         assertEquals(0, foundKeyList.size());
58         
59         foundKeyList = TreeMapUtils.findMatchingEntries(testTreeMap, "J");
60         assertEquals("JA", foundKeyList.get(0).getKey());
61         
62         foundKeyList = TreeMapUtils.findMatchingEntries(testTreeMap, "JA");
63         assertEquals("JA", foundKeyList.get(0).getKey());
64         
65         foundKeyList = TreeMapUtils.findMatchingEntries(testTreeMap, "JB");
66         assertEquals(0, foundKeyList.size());
67
68         foundKeyList = TreeMapUtils.findMatchingEntries(testTreeMap, "JO");
69         assertEquals("JOE", foundKeyList.get(0).getKey());
70         
71         foundKeyList = TreeMapUtils.findMatchingEntries(testTreeMap, "JOE");
72         assertEquals("JOE", foundKeyList.get(0).getKey());
73         
74         foundKeyList = TreeMapUtils.findMatchingEntries(testTreeMap, "JOS");
75         assertEquals("JOSH", foundKeyList.get(0).getKey());
76         
77         foundKeyList = TreeMapUtils.findMatchingEntries(testTreeMap, "JOSH");
78         assertEquals("JOSH", foundKeyList.get(0).getKey());
79         
80         foundKeyList = TreeMapUtils.findMatchingEntries(testTreeMap, "K");
81         assertEquals("K", foundKeyList.get(0).getKey());
82         
83         foundKeyList = TreeMapUtils.findMatchingEntries(testTreeMap, "L");
84         assertEquals(0, foundKeyList.size());
85     }
86 }