Divide the MSB source codes into two repos
[msb/apigateway.git] / apiroute / apiroute-service / src / test / java / org / onap / msb / apiroute / wrapper / util / CommonUtilTest.java
1 package org.onap.msb.apiroute.wrapper.util;
2
3 import java.util.HashSet;
4 import java.util.Set;
5
6 import org.junit.Assert;
7 import org.junit.Test;
8 import org.onap.msb.apiroute.wrapper.util.CommonUtil;
9
10 public class CommonUtilTest {
11
12
13   
14   @Test
15   public void test_concat() {
16     Object[] str1 = new String[] {"test1", "test2"};
17     Object[] str2 = new String[] {"test3"};
18     Object[] str3 = CommonUtil.concat(str1, str2);
19
20     Assert.assertEquals(3, str3.length);
21   }
22
23   @Test
24   public void test_containStr() {
25     String value = "1";
26     String array[] = {"1", "2"};
27     Assert.assertTrue(CommonUtil.contain(array, value));
28     Assert.assertFalse(CommonUtil.contain(array, "3"));
29   }
30
31   @Test
32   public void test_containArray() {
33     String value[] = {"0"};
34     String array[] = {"1", "2"};
35     String array2[] = {"2", "1"};
36     Assert.assertFalse(CommonUtil.contain(array, value));
37     Assert.assertTrue(CommonUtil.contain(array, array2));
38   }
39
40   @Test
41   public void test_containStrArray() {
42     Assert.assertFalse(CommonUtil.contain("0,1,2", "3"));
43     Assert.assertTrue(CommonUtil.contain("0,1,2", "1"));
44   }
45
46   @Test
47   public void test_getDiffrent() {
48     Set<String> list1 = new HashSet<String>();
49     list1.add("test1");
50     list1.add("test2");
51
52     Set<String> list2 = new HashSet<String>();
53     list2.add("test2");
54     list2.add("test3");
55
56     Set<String> diff = CommonUtil.getDiffrent(list1, list2);
57     Assert.assertEquals(1, diff.size());
58     Assert.assertTrue(diff.contains("test3"));
59   }
60
61 }