fix powermock issue
[msb/apigateway.git] / apiroute / apiroute-service / src / test / java / org / onap / msb / apiroute / wrapper / util / CommonUtilTest.java
1 /*******************************************************************************
2  * Copyright 2016-2017 ZTE, Inc. and others.
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5  * in compliance with the License. You may obtain a copy of the License at
6  * 
7  * http://www.apache.org/licenses/LICENSE-2.0
8  * 
9  * Unless required by applicable law or agreed to in writing, software distributed under the License
10  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11  * or implied. See the License for the specific language governing permissions and limitations under
12  * the License.
13  ******************************************************************************/
14 package org.onap.msb.apiroute.wrapper.util;
15
16 import java.util.HashSet;
17 import java.util.Set;
18
19 import org.junit.Assert;
20 import org.junit.Test;
21
22 public class CommonUtilTest {
23
24
25
26     @Test
27     public void test_concat() {
28         Object[] str1 = new String[] {"test1", "test2"};
29         Object[] str2 = new String[] {"test3"};
30         Object[] str3 = CommonUtil.concat(str1, str2);
31
32         Assert.assertEquals(3, str3.length);
33     }
34
35     @Test
36     public void test_containStr() {
37         String value = "1";
38         String array[] = {"1", "2"};
39         Assert.assertTrue(CommonUtil.contain(array, value));
40         Assert.assertFalse(CommonUtil.contain(array, "3"));
41     }
42
43     @Test
44     public void test_containArray() {
45         String value[] = {"0"};
46         String array[] = {"1", "2"};
47         String array2[] = {"2", "1"};
48         Assert.assertFalse(CommonUtil.contain(array, value));
49         Assert.assertTrue(CommonUtil.contain(array, array2));
50     }
51
52     @Test
53     public void test_containStrArray() {
54         Assert.assertFalse(CommonUtil.contain("0,1,2", "3"));
55         Assert.assertTrue(CommonUtil.contain("0,1,2", "1"));
56     }
57
58     @Test
59     public void test_getDiffrent() {
60         Set<String> list1 = new HashSet<String>();
61         list1.add("test1");
62         list1.add("test2");
63
64         Set<String> list2 = new HashSet<String>();
65         list2.add("test2");
66         list2.add("test3");
67
68         Set<String> diff = CommonUtil.getDiffrent(list1, list2);
69         Assert.assertEquals(1, diff.size());
70         Assert.assertTrue(diff.contains("test3"));
71     }
72
73 }