package com.demo2do.core.utils;

import org.junit.Assert;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

public class CommonUtilTest {

    @Test
    public void testDeduplicate() {
        List<String> list = new ArrayList<String>();
        list.add("one");
        list.add("two");
        list.add("two");
        list.add("three");
        Assert.assertEquals("deduplicate 'two'", list.size() - 1, CommonUtil.deduplicate(list).size());
        for (String element : CommonUtil.deduplicate(list)) {
            System.out.println(element);
        }
    }

    @Test
    public void testDeduplicatedMerge() {
        List<Integer> list1 = new ArrayList<Integer>();
        list1.add(1);
        list1.add(2);
        list1.add(3);
        list1.add(3);
        List<Integer> list2 = new ArrayList<Integer>();
        list2.add(3);
        list2.add(3);
        list2.add(4);
        list2.add(5);
        Assert.assertEquals(list1.size() + list2.size() - 3, CommonUtil.deduplicatedMerge(list1, list2).size());
        for (Integer element : CommonUtil.deduplicatedMerge(list1, list2)) {
            System.out.println(element);
        }
    }
}

@@ -363,102 +363,121 @@
 %22);%0A
-        Assert.assertEquals(%22deduplicate 'two'%22, list.size() - 1, CommonUtil.deduplicate(list)
+%0A        List%3CString%3E result = CommonUtil.deduplicate(list);%0A%0A        Assert.assertEquals(list.size() - 1, result
 .siz
@@ -478,32 +478,33 @@
 lt.size());%0A
+%0A
         
 for (String 
@@ -495,112 +495,195 @@
     
-for (String element : CommonUtil.deduplicate(list)) %7B%0A            System.out.println(element);%0A        %7D
+System.out.println();%0A        System.out.println(%22Test Deduplicate%22);%0A        System.out.println(%22original list:     %22 + list);%0A        System.out.println(%22after deduplicate: %22 + result);
 %0A   
@@ -1026,16 +1026,93 @@
 add(5);%0A
+%0A        List%3CInteger%3E result = CommonUtil.deduplicatedMerge(list1, list2);%0A%0A
         
@@ -1168,50 +1168,14 @@
  3, 
-CommonUtil.deduplicatedMerge(list1, list2)
+result
 .siz
@@ -1180,24 +1180,25 @@
 ize());%0A
+%0A
         
 for (Int
@@ -1193,43 +1193,64 @@
     
-for (Integer element : CommonUtil.d
+System.out.println();%0A        System.out.println(%22Test D
 edup
@@ -1260,81 +1260,258 @@
 ated
+ 
 Merge
-(list1, list2)) %7B%0A            System.out.println(element);%0A        %7D
+%22);%0A        System.out.println(%22original%22);%0A        System.out.println(%22list1:  %22 + list1);%0A        System.out.println(%22list2:  %22 + list2);%0A        System.out.println(%22after deduplicated merge%22);%0A        System.out.println(%22result: %22 + result);
 %0A   

restructure output for test case