public void testComplex() throws Exception {
rpn1.setTerm("left");
rpn2.setTerm("right");
RootNode comRoot = new RootNode();
ComplexNode complex = new ComplexNode(comRoot, rpn1, rpn2);
complex.setOp(ComplexNode.COMPLEX_OR);
Query retQuery = converter.toLuceneQuery((QueryNode) complex);
String term = retQuery.toString(ALL_FIELDS);
LOGGER.fine("Complex OR term is " + term);
assertTrue(term.equals("title:left origin:right"));
//RootNode comRoot2 = new RootNode();
rpn1.setTerm("or");
ComplexNode complex2 = new ComplexNode(comRoot, rpn1, rpn2);
complex2.setOp(ComplexNode.COMPLEX_AND);
retQuery = converter.toLuceneQuery((QueryNode) complex2);
term = retQuery.toString(ALL_FIELDS);
LOGGER.fine("Complex AND term is " + term);
assertTrue(term.equals("+title:or +origin:right"));
AttrPlusTermNode rpn3 = new AttrPlusTermNode(root1);
rpn3.setAttr(null, new Integer(GeoProfile.USE), new Integer(TITLE_NUM));
rpn3.setTerm("nor");
AttrPlusTermNode rpn4 = new AttrPlusTermNode(root2);
rpn4.setAttr(null, new Integer(GeoProfile.USE), new Integer(ORIGIN_NUM));
rpn4.setTerm("not");
ComplexNode complex3 = new ComplexNode(comRoot, rpn3, rpn4);
complex3.setOp(ComplexNode.COMPLEX_ANDNOT);
retQuery = converter.toLuceneQuery((QueryNode) complex3);
term = retQuery.toString(ALL_FIELDS);
LOGGER.fine("Complex ANDNOT term is " + term);
assertTrue(term.equals("+title:nor -origin:not"));
ComplexNode uber = new ComplexNode(comRoot, complex, complex3);
uber.setOp(ComplexNode.COMPLEX_AND);
retQuery = converter.toLuceneQuery((QueryNode) uber);
term = retQuery.toString(ALL_FIELDS);
LOGGER.fine("Uber complex term is " + term);
assertTrue(term.equals("+(title:or origin:right) "
+ "+(+title:nor -origin:not)"));