@Test
public void testMerge() {

    try {
        // 1 < A < 10
        IFilter filter = and(filter("A", 1, OPERATION.GT), filter("A", 10, OPERATION.LT));
        Assert.assertEquals("(A > 1 AND A < 10)", FilterUtils.merge(filter).toString());
        // 1 < A <= 10, 2 <= A < 11
        filter = and(filter("A", 1, OPERATION.GT), filter("A", 10, OPERATION.LT_EQ));
        filter = newAnd(and(filter("A", 2, OPERATION.GT_EQ), filter("A", 11, OPERATION.LT)), filter);
        Assert.assertEquals("(A >= 2 AND A <= 10)", FilterUtils.merge(filter).toString());
    } catch (EmptyResultFilterException e) {
        Assert.fail();
    }
    try {
        // 1 < A , A < 0
        IFilter filter = and(filter("A", 1, OPERATION.GT), filter("A", 0, OPERATION.LT));
        FilterUtils.merge(filter);
        Assert.fail();// 不可能到这一步
    } catch (EmptyResultFilterException e) {
    }
    try {
        // A > 1 or A < 3
        IFilter filter = or(filter("A", 1, OPERATION.GT), filter("A", 3, OPERATION.LT));
        Assert.assertEquals("1", FilterUtils.merge(filter).toString());
        // A > 1 or A > 3
        filter = or(filter("A", 1, OPERATION.GT), filter("A", 3, OPERATION.GT));
        Assert.assertEquals("A > 1", FilterUtils.merge(filter).toString());
        // A > 1 or A = 5
        filter = or(filter("A", 1, OPERATION.GT), filter("A", 5, OPERATION.EQ));
        Assert.assertEquals("A > 1", FilterUtils.merge(filter).toString());
    } catch (EmptyResultFilterException e) {
        Assert.fail();
    }
    try {
        // A >= 3 or A <= 1 or A in (2)
        IFilter filter = or(or(filter("A", 3, OPERATION.GT_EQ), filter("A", 1, OPERATION.LT_EQ)),
            filter("A", Arrays.asList(1, 2, 3, 4), OPERATION.IN));
        Assert.assertEquals("(A IN [1, 2, 3, 4] OR A >= 3 OR A <= 1)", FilterUtils.merge(filter).toString());
    } catch (EmptyResultFilterException e) {
        Assert.fail();
    }
}