SolrQueryTranslator extends
        AbstractQueryTranslator<String, SolrOrderings, List<String>> implements
        QueryTranslator<String, SolrOrderings, List<String>> { @Override public SolrOrderings order(String fieldName, Order o) { return new SolrOrderings(new SolrOrdering(fieldName, (Order.ASCENDING.equals(o) ? SolrQuery.ORDER.asc : SolrQuery.ORDER.desc))); } SolrQueryTranslator(PropertyResolver propertyResolver); @Override String eq(String fieldName, Object value); @Override String ne(String fieldName, Object value); @Override String lt(String fieldName, Object value); @Override String lte(String fieldName, Object value); @Override String gt(String fieldName, Object value); @Override String gte(String fieldName, Object value); @Override String between(String fieldName, Object from, Object to); @Override String in(String fieldName, Object[] values); @Override String notIn(String fieldName, Object[] values); @Override String contains(String fieldName, Object[] values); @Override String isNull(String fieldName); @Override String notNull(String fieldName); @Override String isEmpty(String fieldName); @Override String notEmpty(String fieldName); @Override String within(String fieldName,
            Point<N> center, Number distance); SolrSpatialQuery getSpatialQuery(Query<T, R> query); @Override String and(String... subqueries); @Override String or(String... subqueries); @Override SolrOrderings order(String fieldName, Order o); @Override SolrOrderings order(SolrOrderings... orderings); @Override List<String> translateProjection(Query<T, R> query); static final String TIMESTAMP_FORMAT; }
@Test public void ordering_asc() { SolrOrderings orderings = translator.order(property, Order.ASCENDING); List<SolrOrdering> list = orderings.get(); assertEquals(1, list.size()); SolrOrdering ordering = list.get(0); assertEquals(property, ordering.getField()); assertEquals(SolrQuery.ORDER.asc, ordering.getOrder()); }
@Test public void ordering_desc() { SolrOrderings orderings = translator.order(property, Order.DESCENDING); List<SolrOrdering> list = orderings.get(); assertEquals(1, list.size()); SolrOrdering ordering = list.get(0); assertEquals(property, ordering.getField()); assertEquals(SolrQuery.ORDER.desc, ordering.getOrder()); }
@Test public void translateOrdering_many() { SolrOrderings[] orders = new SolrOrderings[] { new SolrOrderings(new SolrOrdering("property1", SolrQuery.ORDER.asc)), new SolrOrderings(new SolrOrdering("property2", SolrQuery.ORDER.desc)), new SolrOrderings(new SolrOrdering("property3", SolrQuery.ORDER.asc)), new SolrOrderings(new SolrOrdering("property4", SolrQuery.ORDER.desc))}; SolrOrderings expected = SolrOrderings.merge(orders); SolrOrderings actual = translator.order(orders); assertEquals(4, actual.get().size()); assertEquals(expected.get(), actual.get()); }