@Test public void testRowSort() { RowSortQueryInfoBean bean = new RowSortQueryInfoBean(); SortBean sortBean = new SortBean(); sortBean.setType(SortType.DESC); sortBean.setName("a"); bean.setSortBeans(Collections.singletonList(sortBean)); Dimension dimension = new GroupDimension(0, new ColumnKey("dim"), Groups.newGroup(new NoGroupRule()), new AscSort(0), new IndexInfoImpl(true, false)); MetricBean metricBean = new MetricBean(); metricBean.setColumn("a"); metricBean.setType(AggregatorType.SUM); GroupQueryInfoBean mock = Mockito.mock(GroupQueryInfoBean.class); Mockito.when(mock.getAggregations()).thenReturn(Collections.<AggregationBean>emptyList()); Mockito.when(mock.getPostAggregations()).thenReturn(Collections.<PostQueryInfoBean>emptyList()); List<PostQueryInfo> infoList = PostQueryInfoParser.parse(null, mock, Collections.singletonList(dimension)); assertEquals(1, infoList.size()); assertEquals(PostQueryType.ROW_SORT, infoList.get(0).getType()); RowSortQueryInfo info = (RowSortQueryInfo) infoList.get(0); assertEquals(1, info.getSortList().size()); Sort sort = info.getSortList().get(0); assertEquals(SortType.DESC, sort.getSortType()); assertEquals(1, sort.getTargetIndex()); }
static List<PostQueryInfo> parse(SourceKey table, GroupQueryInfoBean queryInfoBean, List<Dimension> dimensions) { List<PostQueryInfoBean> postAggregations = queryInfoBean.getPostAggregations(); List<AggregationBean> aggregations = queryInfoBean.getAggregations(); Map<String, Integer> fieldIndexMap = getFieldIndexMap(postAggregations, aggregations); List<PostQueryInfo> postQueryInfoList = new ArrayList<PostQueryInfo>(); for (PostQueryInfoBean bean : postAggregations) { postQueryInfoList.add(parse(table, dimensions.size(), bean, fieldIndexMap, aggregations)); } return postQueryInfoList; }
PostQueryInfoParser { static List<PostQueryInfo> parse(SourceKey table, GroupQueryInfoBean queryInfoBean, List<Dimension> dimensions) { List<PostQueryInfoBean> postAggregations = queryInfoBean.getPostAggregations(); List<AggregationBean> aggregations = queryInfoBean.getAggregations(); Map<String, Integer> fieldIndexMap = getFieldIndexMap(postAggregations, aggregations); List<PostQueryInfo> postQueryInfoList = new ArrayList<PostQueryInfo>(); for (PostQueryInfoBean bean : postAggregations) { postQueryInfoList.add(parse(table, dimensions.size(), bean, fieldIndexMap, aggregations)); } return postQueryInfoList; } }
PostQueryInfoParser { static List<PostQueryInfo> parse(SourceKey table, GroupQueryInfoBean queryInfoBean, List<Dimension> dimensions) { List<PostQueryInfoBean> postAggregations = queryInfoBean.getPostAggregations(); List<AggregationBean> aggregations = queryInfoBean.getAggregations(); Map<String, Integer> fieldIndexMap = getFieldIndexMap(postAggregations, aggregations); List<PostQueryInfo> postQueryInfoList = new ArrayList<PostQueryInfo>(); for (PostQueryInfoBean bean : postAggregations) { postQueryInfoList.add(parse(table, dimensions.size(), bean, fieldIndexMap, aggregations)); } return postQueryInfoList; }  }
PostQueryInfoParser { static List<PostQueryInfo> parse(SourceKey table, GroupQueryInfoBean queryInfoBean, List<Dimension> dimensions) { List<PostQueryInfoBean> postAggregations = queryInfoBean.getPostAggregations(); List<AggregationBean> aggregations = queryInfoBean.getAggregations(); Map<String, Integer> fieldIndexMap = getFieldIndexMap(postAggregations, aggregations); List<PostQueryInfo> postQueryInfoList = new ArrayList<PostQueryInfo>(); for (PostQueryInfoBean bean : postAggregations) { postQueryInfoList.add(parse(table, dimensions.size(), bean, fieldIndexMap, aggregations)); } return postQueryInfoList; }   }
PostQueryInfoParser { static List<PostQueryInfo> parse(SourceKey table, GroupQueryInfoBean queryInfoBean, List<Dimension> dimensions) { List<PostQueryInfoBean> postAggregations = queryInfoBean.getPostAggregations(); List<AggregationBean> aggregations = queryInfoBean.getAggregations(); Map<String, Integer> fieldIndexMap = getFieldIndexMap(postAggregations, aggregations); List<PostQueryInfo> postQueryInfoList = new ArrayList<PostQueryInfo>(); for (PostQueryInfoBean bean : postAggregations) { postQueryInfoList.add(parse(table, dimensions.size(), bean, fieldIndexMap, aggregations)); } return postQueryInfoList; }    }