Added oparent to sdc main
[sdc.git] / catalog-dao / src / test / java / org / openecomp / sdc / be / dao / utils / CollectionUtilsTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019 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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.sdc.be.dao.utils;
22
23 import org.apache.tinkerpop.gremlin.structure.T;
24 import org.junit.Assert;
25 import org.junit.Test;
26
27 import java.util.*;
28
29 public class CollectionUtilsTest {
30
31         @Test
32         public void testMerge() throws Exception {
33                 Set<T> source = null;
34                 Set<T> target = null;
35                 Set<T> result;
36
37                 // test 1
38                 target = null;
39                 result = CollectionUtils.merge(source, target);
40                 Assert.assertEquals(null, result);
41
42                 // test 2
43                 source = null;
44                 result = CollectionUtils.merge(source, target);
45                 Assert.assertEquals(null, result);
46         }
47
48         @Test
49         public void testMerge_1() throws Exception {
50                 Map<String, String> source = new HashMap();
51                 Map<String, String> target = new HashMap();
52                 boolean override = false;
53                 Map<String, String> result;
54
55                 result = CollectionUtils.merge(source, target, override);
56                 Assert.assertEquals(null, result);
57                 
58                 // test 1
59                 target = null;
60                 result = CollectionUtils.merge(source, target, override);
61                 Assert.assertEquals(null, result);
62
63                 // test 2
64                 source = null;
65                 result = CollectionUtils.merge(source, target, override);
66                 Assert.assertEquals(null, result);
67         }
68
69         @Test
70         public void testMerge_2() throws Exception {
71                 List<T> source = new LinkedList<>();
72                 List<T> target = new LinkedList<>();
73                 List<T> result;
74
75                 // test 1
76                 result = CollectionUtils.merge(source, target);
77                 Assert.assertEquals(target, result);
78         }
79 }