@Test
  public void updatingWithSameKeysDifferentValuesAfterRemovingUsingInplaceModificationShouldReinsertIndexMappingsWithTwoRegionPuts()
      throws Exception {
    AttributesFactory af = new AttributesFactory();
    af.setScope(Scope.LOCAL);
    region = CacheUtils.createRegion("portfolio", af.create(), false);
    qs = CacheUtils.getQueryService();
    Index keyIndex1 = qs.createIndex(INDEX_NAME, "positions[*]", SEPARATOR + "portfolio");

    Portfolio p1 = new Portfolio(1, 1);
    HashMap map1 = new HashMap();
    map1.put("SUN", 1);
    map1.put("IBM", 2);
    p1.positions = map1;
    region.put(1, p1);

    Portfolio p2 = new Portfolio(1, 1);
    HashMap map2 = new HashMap();
    map2.put("SUN", 5);
    map2.put("IBM", 6);
    p2.positions = map2;
    region.put(2, p2);

    SelectResults results = (SelectResults) qs
        .newQuery("select * from " + SEPARATOR + "portfolio p where p.positions['SUN'] = 1")
        .execute();
    assertEquals(1, results.size());

    map1.remove("SUN");
    map1.remove("IBM");
    map1.put("GOOG", 1);

    region.put(1, p1);

    results = (SelectResults) qs
        .newQuery("select * from " + SEPARATOR + "portfolio p where p.positions['SUN'] = 1")
        .execute();
    assertEquals(0, results.size());

    Portfolio p3 = new Portfolio(1, 1);
    HashMap map3 = new HashMap();
    p3.positions = map3;
    map3.put("SUN", 3);
    map3.put("IBM", 4);
    region.put(1, p3);

    results = (SelectResults) qs
        .newQuery("select * from " + SEPARATOR + "portfolio p where p.positions['SUN'] = 1")
        .execute();
    assertEquals(0, results.size());

    results = (SelectResults) qs
        .newQuery("select * from " + SEPARATOR + "portfolio p where p.positions['SUN'] = 3")
        .execute();
    assertEquals(1, results.size());

    results = (SelectResults) qs
        .newQuery("select * from " + SEPARATOR + "portfolio p where p.positions['GOOG'] = 1")
        .execute();

    assertEquals(0, results.size());
  }
Test index object's comapreTo Function implementation correctness for indexes.
geode-core/src/integrationTest/java/org/apache/geode/cache/query/internal/index/MapRangeIndexMaintenanceJUnitTest.java