use of com.yahoo.elide.core.sort.SortingImpl in project elide by yahoo.
the class ViewTest method testNestedRelationshipAttribute.
@Test
public void testNestedRelationshipAttribute() throws Exception {
Map<String, Sorting.SortOrder> sortMap = new TreeMap<>();
sortMap.put("countryViewIsoCode", Sorting.SortOrder.desc);
Query query = Query.builder().source(playerStatsWithViewSchema).metricProjection(playerStatsWithViewSchema.getMetricProjection("lowScore")).dimensionProjection(playerStatsWithViewSchema.getDimensionProjection("countryViewViewIsoCode")).sorting(new SortingImpl(sortMap, PlayerStatsWithView.class, dictionary)).build();
List<Object> results = toList(engine.executeQuery(query, transaction).getData());
PlayerStatsWithView usa0 = new PlayerStatsWithView();
usa0.setId("0");
usa0.setLowScore(35);
usa0.setCountryViewViewIsoCode("USA");
PlayerStatsWithView hk1 = new PlayerStatsWithView();
hk1.setId("1");
hk1.setLowScore(72);
hk1.setCountryViewViewIsoCode("HKG");
assertEquals(2, results.size());
assertEquals(usa0, results.get(0));
assertEquals(hk1, results.get(1));
// the join would not happen for a view join
PlayerStatsWithView actualStats1 = (PlayerStatsWithView) results.get(0);
assertNull(actualStats1.getCountry());
}
use of com.yahoo.elide.core.sort.SortingImpl in project elide by yahoo.
the class ViewTest method testNestedViewAttribute.
@Test
public void testNestedViewAttribute() throws Exception {
Map<String, Sorting.SortOrder> sortMap = new TreeMap<>();
sortMap.put("countryViewIsoCode", Sorting.SortOrder.desc);
Query query = Query.builder().source(playerStatsWithViewSchema).metricProjection(playerStatsWithViewSchema.getMetricProjection("lowScore")).dimensionProjection(playerStatsWithViewSchema.getDimensionProjection("countryViewViewIsoCode")).sorting(new SortingImpl(sortMap, PlayerStatsWithView.class, dictionary)).build();
List<Object> results = toList(engine.executeQuery(query, transaction).getData());
PlayerStatsWithView usa0 = new PlayerStatsWithView();
usa0.setId("0");
usa0.setLowScore(35);
usa0.setCountryViewViewIsoCode("USA");
PlayerStatsWithView hk1 = new PlayerStatsWithView();
hk1.setId("1");
hk1.setLowScore(72);
hk1.setCountryViewViewIsoCode("HKG");
assertEquals(2, results.size());
assertEquals(usa0, results.get(0));
assertEquals(hk1, results.get(1));
// the join would not happen for a view join
PlayerStatsWithView actualStats1 = (PlayerStatsWithView) results.get(0);
assertNull(actualStats1.getCountry());
}
use of com.yahoo.elide.core.sort.SortingImpl in project elide by yahoo.
the class ViewTest method testSortingNestedViewAttribute.
@Test
public void testSortingNestedViewAttribute() throws Exception {
Map<String, Sorting.SortOrder> sortMap = new TreeMap<>();
sortMap.put("countryViewViewIsoCode", Sorting.SortOrder.desc);
Query query = Query.builder().source(playerStatsWithViewSchema).metricProjection(playerStatsWithViewSchema.getMetricProjection("lowScore")).dimensionProjection(playerStatsWithViewSchema.getDimensionProjection("countryViewViewIsoCode")).sorting(new SortingImpl(sortMap, PlayerStatsWithView.class, dictionary)).build();
List<Object> results = toList(engine.executeQuery(query, transaction).getData());
PlayerStatsWithView usa0 = new PlayerStatsWithView();
usa0.setId("0");
usa0.setLowScore(35);
usa0.setCountryViewViewIsoCode("USA");
PlayerStatsWithView hk1 = new PlayerStatsWithView();
hk1.setId("1");
hk1.setLowScore(72);
hk1.setCountryViewViewIsoCode("HKG");
assertEquals(2, results.size());
assertEquals(usa0, results.get(0));
assertEquals(hk1, results.get(1));
// the join would not happen for a view join
PlayerStatsWithView actualStats1 = (PlayerStatsWithView) results.get(0);
assertNull(actualStats1.getCountry());
}
use of com.yahoo.elide.core.sort.SortingImpl in project elide by yahoo.
the class AbstractHQLQueryBuilderTest method testSortClauseWithComplexAttribute.
@Test
public void testSortClauseWithComplexAttribute() {
Map<String, Sorting.SortOrder> sorting = new LinkedHashMap<>();
sorting.put("price.total", Sorting.SortOrder.asc);
String actual = getSortClause(new SortingImpl(sorting, Book.class, dictionary));
String expected = " order by example_Book.price.total asc";
assertEquals(expected, actual);
}
use of com.yahoo.elide.core.sort.SortingImpl in project elide by yahoo.
the class AbstractHQLQueryBuilderTest method testSortClauseWithJoin.
@Test
public void testSortClauseWithJoin() {
Map<String, Sorting.SortOrder> sorting = new LinkedHashMap<>();
sorting.put(PUBLISHER + PERIOD + NAME, Sorting.SortOrder.asc);
String actual = getSortClause(new SortingImpl(sorting, Book.class, dictionary));
String expected = " order by example_Book_publisher.name asc";
assertEquals(expected, actual);
}
Aggregations