@Test
    public void testDifference() throws Exception {
        List<String> s1 = Arrays.asList("111", "222", "333");
        List<String> s2 = Arrays.asList("111", "333", "444", "555", "666");

        ListDifference difference = new ListDifference(s1, s2);
        Assert.assertFalse(difference.areEqual());

        List<String> add = difference.getOnlyOnRight();
        List<String> removed = difference.getOnlyOnLeft();
        List<String> same = difference.getOnBoth();

        Assert.assertEquals(add.size(), 3);
        Assert.assertEquals(removed.size(), 1);
        Assert.assertEquals(same.size(), 2);

        Assert.assertEquals(add.get(0), "444");
        Assert.assertEquals(removed.get(0), "222");

        s1 = Arrays.asList("111", "222", "333");
        s2 = Arrays.asList("111", "333", "222");

        difference = new ListDifference(s1, s2);
        Assert.assertTrue(difference.areEqual());

        add = difference.getOnlyOnRight();
        removed = difference.getOnlyOnLeft();
        same = difference.getOnBoth();

        Assert.assertEquals(add.size(), 0);
        Assert.assertEquals(removed.size(), 0);
        Assert.assertEquals(same.size(), 3);

        s1 = new ArrayList<String>();
        s2 = Arrays.asList();
        difference = new ListDifference(s1, s2);
        Assert.assertTrue(difference.areEqual());

        s1 = null;
        s2 = Arrays.asList();
        difference = new ListDifference(s1, s2);
        Assert.assertTrue(difference.areEqual());

        s1 = Collections.emptyList();
        s2 = null;
        difference = new ListDifference(s1, s2);
        Assert.assertTrue(difference.areEqual());
    }
@author <a href="mailto:zhanggeng.zg@antfin.com">GengZhang</a>
core/common/src/test/java/com/alipay/sofa/rpc/common/struct/ListDifferenceTest.java