@Test
  public void testOrganizedOperandsSingleCondnEvalMultipleGreaterThanInEqualities_AND() {
    LogWriter logger = CacheUtils.getCache().getLogger();
    try {
      CompiledComparison[] cv = null;
      ExecutionContext context = new QueryExecutionContext(null, CacheUtils.getCache());
      bindIteratorsAndCreateIndex(context);
      /** **********For ALL greater or greater than combinations********* */
      // Case 1 : a >7 and a >=4 and a > 5 and a > 7
      cv = new CompiledComparison[4];
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_GT);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(4), OQLLexerTokenTypes.TOK_GE);
      cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(5), OQLLexerTokenTypes.TOK_GT);
      cv[3] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_GT);

      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[0] || oo1.filterOperand == cv[3]);
      // Case2: a>=8 and a >4 and a>=6 and a>=8
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(8), OQLLexerTokenTypes.TOK_GE);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(4), OQLLexerTokenTypes.TOK_GE);
      cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(6), OQLLexerTokenTypes.TOK_GE);
      cv[3] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(8), OQLLexerTokenTypes.TOK_GE);

      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 : 7 < a and a >=4 and a > 5 and a >= 7 and a != 15
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_GE);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(4), OQLLexerTokenTypes.TOK_GE);
      cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(5), OQLLexerTokenTypes.TOK_GT);
      cv[3] = new CompiledComparison(new CompiledLiteral(7),
          new CompiledPath(new CompiledID("p"), "ID"), OQLLexerTokenTypes.TOK_LT);
      cv[4] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(15), 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_GT);
      assertTrue(
          RangeJunction.getSingleCondnEvaluatorKey(oo1.filterOperand).equals(7));
      assertTrue(RangeJunction.getIndex(oo1.filterOperand).getName().equals("idIndex"));
      assertTrue(RangeJunction.getKeysToBeRemoved(oo1.filterOperand).size() == 1 && RangeJunction
          .getKeysToBeRemoved(oo1.filterOperand).iterator().next().equals(15));
      // Case 4 : 7 < a and a >=7
      cv = new CompiledComparison[2];
      cv[0] = new CompiledComparison(new CompiledLiteral(7),
          new CompiledPath(new CompiledID("p"), "ID"), OQLLexerTokenTypes.TOK_LT);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_GE);
      oo = oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv,
          context);
      rj = (RangeJunction) oo.filterOperand;
      oo1 = rj.organizeOperands(context);
      assertTrue(oo1.filterOperand == cv[0]);
      // 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_GT);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_GE);
      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_GE);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_GT);
      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 >7
      cv = new CompiledComparison[2];
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(8), OQLLexerTokenTypes.TOK_GE);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_GT);
      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 > =7
      cv = new CompiledComparison[2];
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(8), OQLLexerTokenTypes.TOK_GE);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_GE);
      oo = oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv,
          context);
      rj = (RangeJunction) oo.filterOperand;
      oo1 = rj.organizeOperands(context);
      assertTrue(oo1.filterOperand == cv[0]);

      // Case 9 : a >=7 and a > =8
      cv = new CompiledComparison[2];
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_GE);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(8), OQLLexerTokenTypes.TOK_GE);
      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 != 13
      cv = new CompiledComparison[3];
      cv[0] = new CompiledComparison(new CompiledLiteral(7),
          new CompiledPath(new CompiledID("p"), "ID"), OQLLexerTokenTypes.TOK_LT);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_GE);
      cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(13), 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_GT);

      // Case 11 : a > 7 and a >=7 and a != 13
      cv = new CompiledComparison[3];
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_GT);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_GE);
      cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(13), 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_GT);

      // Case 12 : a >= 7 and a >7 and a != 13
      cv = new CompiledComparison[3];
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_GE);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_GT);
      cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(13), 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_GT);

      // Case 13 : a >= 8 and a >7 and a != 13
      cv = new CompiledComparison[3];
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(8), OQLLexerTokenTypes.TOK_GE);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_GT);
      cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(13), 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_GE);

      // Case 14 : a >=8 and a > =7 and a !=13
      cv = new CompiledComparison[3];
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(8), OQLLexerTokenTypes.TOK_GE);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_GE);
      cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(13), 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_GE);

      // Case 15 : a >=7 and a > =8 and a != 13
      cv = new CompiledComparison[3];
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_GE);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(8), OQLLexerTokenTypes.TOK_GE);
      cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(13), 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_GE);
      // Case 15 : a >=7 and a > =8 and a != 8
      cv = new CompiledComparison[3];
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_GE);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(8), OQLLexerTokenTypes.TOK_GE);
      cv[2] = 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(
          RangeJunction.getSingleCondnEvaluatorKey(oo1.filterOperand).equals(8));
      assertTrue(RangeJunction
          .getSingleCondnEvaluatorOperator(oo1.filterOperand) == OQLLexerTokenTypes.TOK_GE);
      assertTrue(RangeJunction.getKeysToBeRemoved((oo1.filterOperand)).iterator().next()
          .equals(8));

      // Case 16 : a >=7 and a > =8 and a != 7
      cv = new CompiledComparison[3];
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_GE);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(8), OQLLexerTokenTypes.TOK_GE);
      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 > =8 and a != 7 and a!=4 and a != 3
      cv = new CompiledComparison[5];
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_GE);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(8), OQLLexerTokenTypes.TOK_GE);
      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(4), OQLLexerTokenTypes.TOK_NE);
      cv[4] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(3), 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 > =8 and a != 7 and a!=4 and a != 3 and a != 20
      // and a != 8
      cv = new CompiledComparison[7];
      cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(7), OQLLexerTokenTypes.TOK_GE);
      cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(8), OQLLexerTokenTypes.TOK_GE);
      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(4), OQLLexerTokenTypes.TOK_NE);
      cv[4] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(3), OQLLexerTokenTypes.TOK_NE);
      cv[5] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"),
          new CompiledLiteral(20), OQLLexerTokenTypes.TOK_NE);
      cv[6] = 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(
          RangeJunction.getSingleCondnEvaluatorKey(oo1.filterOperand).equals(8));
      assertTrue(RangeJunction
          .getSingleCondnEvaluatorOperator(oo1.filterOperand) == OQLLexerTokenTypes.TOK_GE);
      Iterator itr = RangeJunction.getKeysToBeRemoved((oo1.filterOperand)).iterator();
      Object temp;
      assertTrue((temp = itr.next()).equals(8) || temp.equals(20));
      assertTrue((temp = itr.next()).equals(8) || temp.equals(20));
      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 GREATER 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