public void testUniqueWithLimitOffset() throws Exception {
    FilterFactory ff = dataStore.getFilterFactory();
    PropertyName p = ff.property(aname("stringProperty"));

    UniqueVisitor v = new MyUniqueVisitor(p);
    Query q = new Query(tname("ft1"));
    q.setStartIndex(0);
    q.setMaxFeatures(2);
    dataStore.getFeatureSource(tname("ft1")).accepts(q, v, null);
    assertFalse(visited);
    Set result = v.getResult().toSet();
    assertEquals(2, result.size());
  }
  public void testUnique() throws Exception {
    FilterFactory ff = dataStore.getFilterFactory();
    PropertyName p = ff.property(aname("stringProperty"));

    UniqueVisitor v = new MyUniqueVisitor(p);
    dataStore.getFeatureSource(tname("ft1")).accepts(Query.ALL, v, null);
    assertFalse(visited);
    Set result = v.getResult().toSet();
    assertEquals(3, result.size());
    assertTrue(result.contains("zero"));
    assertTrue(result.contains("one"));
    assertTrue(result.contains("two"));
  }
  public void testUniqueWithFilter() throws Exception {
    FilterFactory ff = dataStore.getFilterFactory();
    PropertyName p = ff.property(aname("stringProperty"));

    UniqueVisitor v = new MyUniqueVisitor(p);
    Filter f = ff.greater(ff.property(aname("doubleProperty")), ff.literal(1));
    Query q = new Query(tname("ft1"), f);
    dataStore.getFeatureSource(tname("ft1")).accepts(q, v, null);
    assertFalse(visited);
    Set result = v.getResult().toSet();
    assertEquals(2, result.size());
    assertTrue(result.contains("one"));
    assertTrue(result.contains("two"));
  }
  public void testUniqueWithLimitOffsetOnVisitor() throws Exception {

    if (!dataStore.getSQLDialect().isLimitOffsetSupported()
        || !dataStore.getSQLDialect().isAggregatedSortSupported("distinct")) {
      return;
    }

    FilterFactory ff = dataStore.getFilterFactory();
    PropertyName p = ff.property(aname("stringProperty"));

    UniqueVisitor v = new MyUniqueVisitor(p);
    v.setPreserveOrder(true);
    v.setStartIndex(1);
    v.setMaxFeatures(2);
    Query q = new Query(tname("ft1"));
    q.setSortBy(new SortBy[] {new SortByImpl(p, SortOrder.ASCENDING)});
    dataStore.getFeatureSource(tname("ft1")).accepts(q, v, null);
    assertFalse(visited);
    Set result = v.getResult().toSet();
    assertEquals(2, result.size());
    assertEquals("two", result.iterator().next());
  }