use of com.enonic.xp.query.expr.OrderExpr in project xp by enonic.
the class SortBuilderFactoryTest method createFieldSort.
@Test
public void createFieldSort() {
final Set<OrderExpr> orderExprs = new HashSet<>();
orderExprs.add(new FieldOrderExpr(FieldExpr.from("myField"), OrderExpr.Direction.ASC));
final List<SortBuilder> sortBuilders = new SortQueryBuilderFactory(new SearchQueryFieldNameResolver()).create(orderExprs);
assertEquals(1, sortBuilders.size());
assertTrue(sortBuilders.iterator().next() instanceof FieldSortBuilder);
}
use of com.enonic.xp.query.expr.OrderExpr in project xp by enonic.
the class SortBuilderFactoryTest method createFieldWithoutDirectionSort.
@Test
public void createFieldWithoutDirectionSort() {
final Set<OrderExpr> orderExprs = new HashSet<>();
orderExprs.add(new FieldOrderExpr(FieldExpr.from("myField"), null));
final List<SortBuilder> sortBuilders = new SortQueryBuilderFactory(new SearchQueryFieldNameResolver()).create(orderExprs);
assertEquals(1, sortBuilders.size());
assertTrue(sortBuilders.iterator().next() instanceof FieldSortBuilder);
}
use of com.enonic.xp.query.expr.OrderExpr in project xp by enonic.
the class SortBuilderFactoryTest method createGeoDistance.
@Test
public void createGeoDistance() {
final Set<OrderExpr> orderExprs = new HashSet<>();
orderExprs.add(new DynamicOrderExpr(new FunctionExpr("geoDistance", List.of(ValueExpr.string("myField"), ValueExpr.geoPoint("-50,40"), ValueExpr.string("km"))), OrderExpr.Direction.ASC));
final List<SortBuilder> sortBuilders = new SortQueryBuilderFactory(new SearchQueryFieldNameResolver()).create(orderExprs);
assertEquals(1, sortBuilders.size());
assertTrue(sortBuilders.iterator().next() instanceof GeoDistanceSortBuilder);
}
use of com.enonic.xp.query.expr.OrderExpr in project xp by enonic.
the class SortBuilderFactoryTest method createGeoDistanceWithoutDirection.
@Test
public void createGeoDistanceWithoutDirection() {
final Set<OrderExpr> orderExprs = new HashSet<>();
orderExprs.add(new DynamicOrderExpr(new FunctionExpr("geoDistance", List.of(ValueExpr.string("myField"), ValueExpr.geoPoint("-50,40"), ValueExpr.string("km"))), null));
final List<SortBuilder> sortBuilders = new SortQueryBuilderFactory(new SearchQueryFieldNameResolver()).create(orderExprs);
assertEquals(1, sortBuilders.size());
assertTrue(sortBuilders.iterator().next() instanceof GeoDistanceSortBuilder);
}
use of com.enonic.xp.query.expr.OrderExpr in project xp by enonic.
the class SortBuilderFactoryTest method createMultipleFieldSort.
@Test
public void createMultipleFieldSort() {
final Set<OrderExpr> orderExprs = new HashSet<>();
orderExprs.add(new FieldOrderExpr(FieldExpr.from("myField"), OrderExpr.Direction.ASC));
orderExprs.add(new FieldOrderExpr(FieldExpr.from("mySecondField"), OrderExpr.Direction.DESC));
final List<SortBuilder> sortBuilders = new SortQueryBuilderFactory(new SearchQueryFieldNameResolver()).create(orderExprs);
assertEquals(2, sortBuilders.size());
assertTrue(sortBuilders.iterator().next() instanceof FieldSortBuilder);
assertTrue(sortBuilders.iterator().next() instanceof FieldSortBuilder);
}
Aggregations