@Test
  public void testFlatten() throws Exception {
    assertEquals("leaf-1", SearchArgumentImpl.BuilderImpl.flatten(leaf(1)).toOldString());
    assertEquals("NO",
        SearchArgumentImpl.BuilderImpl.flatten(constant(TruthValue.NO)).toString());
    assertEquals("(not (not leaf-1))",
        SearchArgumentImpl.BuilderImpl.flatten(not(not(leaf(1)))).toOldString());
    assertEquals("(and leaf-1 leaf-2)",
        SearchArgumentImpl.BuilderImpl.flatten(and(leaf(1), leaf(2))).toOldString());
    assertEquals("(and (or leaf-1 leaf-2) leaf-3)",
        SearchArgumentImpl.BuilderImpl.flatten(and(or(leaf(1), leaf(2)), leaf(3))
        ).toOldString());
    assertEquals("(and leaf-1 leaf-2 leaf-3 leaf-4)",
        SearchArgumentImpl.BuilderImpl.flatten(and(and(leaf(1), leaf(2)),
            and(leaf(3), leaf(4)))).toOldString());
    assertEquals("(or leaf-1 leaf-2 leaf-3 leaf-4)",
        SearchArgumentImpl.BuilderImpl.flatten(or(leaf(1), or(leaf(2), or(leaf(3),
            leaf(4))))).toOldString());
    assertEquals("(or leaf-1 leaf-2 leaf-3 leaf-4)",
        SearchArgumentImpl.BuilderImpl.flatten(or(or(or(leaf(1), leaf(2)), leaf(3)),
            leaf(4))).toOldString());
    assertEquals("(or leaf-1 leaf-2 leaf-3 leaf-4 leaf-5 leaf-6)",
        SearchArgumentImpl.BuilderImpl.flatten(or(or(leaf(1), or(leaf(2), leaf(3))),
            or(or(leaf(4), leaf(5)), leaf(6)))).toOldString());
    assertEquals("(and (not leaf-1) leaf-2 (not leaf-3) leaf-4 (not leaf-5) leaf-6)",
        SearchArgumentImpl.BuilderImpl.flatten(and(and(not(leaf(1)), and(leaf(2),
                not(leaf(3)))), and(and(leaf(4), not(leaf(5))), leaf(6)))
        ).toOldString());
    assertEquals("(not (and leaf-1 leaf-2 leaf-3))",
        SearchArgumentImpl.BuilderImpl.flatten(not(and(leaf(1), and(leaf(2), leaf(3))))
        ).toOldString());
  }
Create a predicate leaf. This is used by another test.
ql/src/test/org/apache/hadoop/hive/ql/io/sarg/TestSearchArgumentImpl.java