1 /*******************************************************************************
2 * Copyright 2016-2017 ZTE, Inc. and others.
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
7 * http://www.apache.org/licenses/LICENSE-2.0
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
13 ******************************************************************************/
14 package org.onap.msb.apiroute.wrapper.util;
16 import java.util.HashSet;
19 import org.junit.Assert;
20 import org.junit.Test;
22 public class CommonUtilTest {
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);
32 Assert.assertEquals(3, str3.length);
36 public void test_containStr() {
38 String array[] = {"1", "2"};
39 Assert.assertTrue(CommonUtil.contain(array, value));
40 Assert.assertFalse(CommonUtil.contain(array, "3"));
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));
53 public void test_containStrArray() {
54 Assert.assertFalse(CommonUtil.contain("0,1,2", "3"));
55 Assert.assertTrue(CommonUtil.contain("0,1,2", "1"));
59 public void test_getDiffrent() {
60 Set<String> list1 = new HashSet<String>();
64 Set<String> list2 = new HashSet<String>();
68 Set<String> diff = CommonUtil.getDiffrent(list1, list2);
69 Assert.assertEquals(1, diff.size());
70 Assert.assertTrue(diff.contains("test3"));