@Test
  public void testOrganizedOperandsSingleCondnEvalMultipleLessThanInEqualities_AND() {
    LogWriter logger = CacheUtils.getCache().getLogger();
    try {
      CompiledComparison[] cv = null;
      ExecutionContext context = new QueryExecutionContext(null, CacheUtils.getCache());
      bindIteratorsAndCreateIndex(context);
      /**
       * ******************For all LESS THAN OR LESS THAN EQUAL To ********************
       */
      // Case 1 : a < 7 and a <=4 and a < 5 and a <=4
      cv = new CompiledComparison[4];
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_LT);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(4), OQLLexerTokenTypes.TOK_LE);
      cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(5), OQLLexerTokenTypes.TOK_LT);
      cv[3] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(4), OQLLexerTokenTypes.TOK_LE);

      OrganizedOperands oo =
          oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv, context);
      assertTrue("Filter Openad of OrganizedOperand is not of type RangeJunction",
          oo.filterOperand instanceof RangeJunction);
      RangeJunction rj = (RangeJunction) oo.filterOperand;
      OrganizedOperands oo1 = rj.organizeOperands(context);
      assertTrue(oo1.filterOperand == cv[1] || oo1.filterOperand == cv[3]);
      // Case2: a<=8 and a < 12 and a <=10 and a<=8
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(8), OQLLexerTokenTypes.TOK_LE);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(12), OQLLexerTokenTypes.TOK_LT);
      cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(10), OQLLexerTokenTypes.TOK_LT);
      cv[3] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(8), OQLLexerTokenTypes.TOK_LT);

      oo = oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv,
          context);
      assertTrue("Filter Openad of OrganizedOperand is not of type RangeJunction",
          oo.filterOperand instanceof RangeJunction);
      rj = (RangeJunction) oo.filterOperand;
      oo1 = rj.organizeOperands(context);
      assertTrue(oo1.filterOperand == cv[0] || oo1.filterOperand == cv[3]);
      cv = new CompiledComparison[5];
      // Case 3 : 3 >= a and a <=4 and a < 5 and a <= 3 and a != 1
      cv[0] = new CompiledComparison(new CompiledLiteral(3),
          new CompiledPath(new CompiledID("p"), "ID"), OQLLexerTokenTypes.TOK_GE);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(4), OQLLexerTokenTypes.TOK_LE);
      cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(5), OQLLexerTokenTypes.TOK_LT);
      cv[3] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(3), OQLLexerTokenTypes.TOK_LE);
      cv[4] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(1), OQLLexerTokenTypes.TOK_NE);
      oo = oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv,
          context);
      rj = (RangeJunction) oo.filterOperand;
      oo1 = rj.organizeOperands(context);
      assertTrue(RangeJunction.isInstanceOfSingleCondnEvaluator(oo1.filterOperand));
      assertTrue(RangeJunction
          .getSingleCondnEvaluatorOperator(oo1.filterOperand) == OQLLexerTokenTypes.TOK_LE);
      assertTrue(
          RangeJunction.getSingleCondnEvaluatorKey(oo1.filterOperand).equals(3));
      assertTrue(RangeJunction.getIndex(oo1.filterOperand).getName().equals("idIndex"));
      assertTrue(RangeJunction.getKeysToBeRemoved(oo1.filterOperand).size() == 1 && RangeJunction
          .getKeysToBeRemoved(oo1.filterOperand).iterator().next().equals(1));
      // Case 4 : 3 > a and a <=2
      cv = new CompiledComparison[2];
      cv[0] = new CompiledComparison(new CompiledLiteral(3),
          new CompiledPath(new CompiledID("p"), "ID"), OQLLexerTokenTypes.TOK_GT);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(2), OQLLexerTokenTypes.TOK_LE);
      oo = oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv,
          context);
      rj = (RangeJunction) oo.filterOperand;
      oo1 = rj.organizeOperands(context);
      assertTrue(oo1.filterOperand == cv[1]);
      // Case 5 : a < 7 and a <=7
      cv = new CompiledComparison[2];
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_LT);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_LE);
      oo = oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv,
          context);
      rj = (RangeJunction) oo.filterOperand;
      oo1 = rj.organizeOperands(context);
      assertTrue(oo1.filterOperand == cv[0]);

      // Case 6 : a <= 7 and a <7
      cv = new CompiledComparison[2];
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_LE);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_LT);
      oo = oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv,
          context);
      rj = (RangeJunction) oo.filterOperand;
      oo1 = rj.organizeOperands(context);
      assertTrue(oo1.filterOperand == cv[1]);

      // Case 7 : a <= 8 and a <9
      cv = new CompiledComparison[2];
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(8), OQLLexerTokenTypes.TOK_LE);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(9), OQLLexerTokenTypes.TOK_LT);
      oo = oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv,
          context);
      rj = (RangeJunction) oo.filterOperand;
      oo1 = rj.organizeOperands(context);
      assertTrue(oo1.filterOperand == cv[0]);

      // Case 8 : a <=8 and a <=10
      cv = new CompiledComparison[2];
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(8), OQLLexerTokenTypes.TOK_LE);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(10), OQLLexerTokenTypes.TOK_LE);
      oo = oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv,
          context);
      rj = (RangeJunction) oo.filterOperand;
      oo1 = rj.organizeOperands(context);
      assertTrue(oo1.filterOperand == cv[0]);

      // Case 9 : a <=6 and a <= 5
      cv = new CompiledComparison[2];
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(6), OQLLexerTokenTypes.TOK_LE);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(5), OQLLexerTokenTypes.TOK_LE);
      oo = oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv,
          context);
      rj = (RangeJunction) oo.filterOperand;
      oo1 = rj.organizeOperands(context);
      assertTrue(oo1.filterOperand == cv[1]);

      // Case 10 : 7 > a and a <=7 and a != 2
      cv = new CompiledComparison[3];
      cv[0] = new CompiledComparison(new CompiledLiteral(7),
          new CompiledPath(new CompiledID("p"), "ID"), OQLLexerTokenTypes.TOK_GT);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_LE);
      cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(2), OQLLexerTokenTypes.TOK_NE);
      oo = oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv,
          context);
      rj = (RangeJunction) oo.filterOperand;
      oo1 = rj.organizeOperands(context);
      assertTrue(
          RangeJunction.getSingleCondnEvaluatorKey(oo1.filterOperand).equals(7));
      assertTrue(RangeJunction
          .getSingleCondnEvaluatorOperator(oo1.filterOperand) == OQLLexerTokenTypes.TOK_LT);
      assertTrue(RangeJunction.getKeysToBeRemoved(oo1.filterOperand).iterator().next()
          .equals(2));
      // Case 11 : a < 7 and a <=7 and a != 1
      cv = new CompiledComparison[3];
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_LT);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_LE);
      cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(1), OQLLexerTokenTypes.TOK_NE);
      oo = oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv,
          context);
      rj = (RangeJunction) oo.filterOperand;
      oo1 = rj.organizeOperands(context);
      assertTrue(
          RangeJunction.getSingleCondnEvaluatorKey(oo1.filterOperand).equals(7));
      assertTrue(RangeJunction
          .getSingleCondnEvaluatorOperator(oo1.filterOperand) == OQLLexerTokenTypes.TOK_LT);
      assertTrue(RangeJunction.getKeysToBeRemoved(oo1.filterOperand).iterator().next()
          .equals(1));
      // Case 12 : a <= 7 and a <7 and a != 1
      cv = new CompiledComparison[3];
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_LE);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_LT);
      cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(1), OQLLexerTokenTypes.TOK_NE);
      oo = oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv,
          context);
      rj = (RangeJunction) oo.filterOperand;
      oo1 = rj.organizeOperands(context);
      assertTrue(
          RangeJunction.getSingleCondnEvaluatorKey(oo1.filterOperand).equals(7));
      assertTrue(RangeJunction
          .getSingleCondnEvaluatorOperator(oo1.filterOperand) == OQLLexerTokenTypes.TOK_LT);
      assertTrue(RangeJunction.getKeysToBeRemoved(oo1.filterOperand).iterator().next()
          .equals(1));
      // Case 13 : a <= 8 and a <9 and a !=1
      cv = new CompiledComparison[3];
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(8), OQLLexerTokenTypes.TOK_LE);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(9), OQLLexerTokenTypes.TOK_LT);
      cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(1), OQLLexerTokenTypes.TOK_NE);
      oo = oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv,
          context);
      rj = (RangeJunction) oo.filterOperand;
      oo1 = rj.organizeOperands(context);
      assertTrue(
          RangeJunction.getSingleCondnEvaluatorKey(oo1.filterOperand).equals(8));
      assertTrue(RangeJunction
          .getSingleCondnEvaluatorOperator(oo1.filterOperand) == OQLLexerTokenTypes.TOK_LE);
      assertTrue(RangeJunction.getKeysToBeRemoved(oo1.filterOperand).iterator().next()
          .equals(1));

      // Case 14 : a <=8 and a <=9 and a !=1
      cv = new CompiledComparison[3];
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(8), OQLLexerTokenTypes.TOK_LE);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(9), OQLLexerTokenTypes.TOK_LE);
      cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(1), OQLLexerTokenTypes.TOK_NE);
      oo = oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv,
          context);
      rj = (RangeJunction) oo.filterOperand;
      oo1 = rj.organizeOperands(context);
      assertTrue(
          RangeJunction.getSingleCondnEvaluatorKey(oo1.filterOperand).equals(8));
      assertTrue(RangeJunction
          .getSingleCondnEvaluatorOperator(oo1.filterOperand) == OQLLexerTokenTypes.TOK_LE);
      assertTrue(RangeJunction.getKeysToBeRemoved(oo1.filterOperand).iterator().next()
          .equals(1));
      // Case 15 : a <=7 and a <=6 and a != 1
      cv = new CompiledComparison[3];
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_LE);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(6), OQLLexerTokenTypes.TOK_LE);
      cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(1), OQLLexerTokenTypes.TOK_NE);

      oo = oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv,
          context);
      rj = (RangeJunction) oo.filterOperand;
      oo1 = rj.organizeOperands(context);
      assertTrue(
          RangeJunction.getSingleCondnEvaluatorKey(oo1.filterOperand).equals(6));
      assertTrue(RangeJunction
          .getSingleCondnEvaluatorOperator(oo1.filterOperand) == OQLLexerTokenTypes.TOK_LE);
      assertTrue(RangeJunction.getKeysToBeRemoved(oo1.filterOperand).iterator().next()
          .equals(1));
      // Case 15 : a <=7 and a <= 6and a != 6
      cv = new CompiledComparison[3];
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_LE);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(6), OQLLexerTokenTypes.TOK_LE);
      cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(6), OQLLexerTokenTypes.TOK_NE);
      oo = oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv,
          context);
      rj = (RangeJunction) oo.filterOperand;
      oo1 = rj.organizeOperands(context);
      assertTrue(
          RangeJunction.getSingleCondnEvaluatorKey(oo1.filterOperand).equals(6));
      assertTrue(RangeJunction
          .getSingleCondnEvaluatorOperator(oo1.filterOperand) == OQLLexerTokenTypes.TOK_LE);
      assertTrue(RangeJunction.getKeysToBeRemoved((oo1.filterOperand)).iterator().next()
          .equals(6));

      // Case 16 : a <=7 and a <=6 and a != 7
      cv = new CompiledComparison[3];
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_LE);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(6), OQLLexerTokenTypes.TOK_LE);
      cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_NE);
      oo = oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv,
          context);
      rj = (RangeJunction) oo.filterOperand;
      oo1 = rj.organizeOperands(context);
      assertTrue(oo1.filterOperand == cv[1]);

      // Case 17 : a <=7 and a <=6 and a != 7 and a!=10 and a != 8
      cv = new CompiledComparison[5];
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_LE);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(6), OQLLexerTokenTypes.TOK_LE);
      cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_NE);
      cv[3] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(10), OQLLexerTokenTypes.TOK_NE);
      cv[4] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(8), OQLLexerTokenTypes.TOK_NE);
      oo = oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv,
          context);
      rj = (RangeJunction) oo.filterOperand;
      oo1 = rj.organizeOperands(context);
      assertTrue(oo1.filterOperand == cv[1]);
      // Case 18 : a <=7 and a <=6 and a != 7 and a!=8 and a !=9 and a != 2 and
      // a != 6
      cv = new CompiledComparison[7];
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_LE);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(6), OQLLexerTokenTypes.TOK_LE);
      cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_NE);
      cv[3] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(8), OQLLexerTokenTypes.TOK_NE);
      cv[4] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(9), OQLLexerTokenTypes.TOK_NE);
      cv[5] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(2), OQLLexerTokenTypes.TOK_NE);
      cv[6] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(6), OQLLexerTokenTypes.TOK_NE);

      oo = oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv,
          context);
      rj = (RangeJunction) oo.filterOperand;
      oo1 = rj.organizeOperands(context);
      assertTrue(
          RangeJunction.getSingleCondnEvaluatorKey(oo1.filterOperand).equals(6));
      assertTrue(RangeJunction
          .getSingleCondnEvaluatorOperator(oo1.filterOperand) == OQLLexerTokenTypes.TOK_LE);
      Iterator itr = RangeJunction.getKeysToBeRemoved((oo1.filterOperand)).iterator();
      Object temp;
      assertTrue((temp = itr.next()).equals(2) || temp.equals(6));
      assertTrue((temp = itr.next()).equals(2) || temp.equals(6));
      assertFalse(itr.hasNext());
      // //////////////////////////////////////////////////////////////
    } catch (Exception e) {
      logger.error(e);
      fail(e.toString());
    }
  }
Tests the functionality of organizedOperands function of a RangeJunction for various
combinations of LESS THAN and Not equal conditions etc which results in a SingleCondnEvaluator
or CompiledComparison for a AND junction. It checks the correctness of the operator & the
evaluated key
geode-core/src/integrationTest/java/org/apache/geode/cache/query/internal/CompiledJunctionInternalsJUnitTest.java