@Test public void testHavingFilter() { HavingFilterQueryInfoBean bean = new HavingFilterQueryInfoBean(); bean.setColumn("a"); FilterInfoBean filterInfoBean = new InFilterBean(); filterInfoBean.setFilterValue(Collections.singleton("1")); bean.setFilter(filterInfoBean); 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); PowerMock.mockStatic(FilterInfoParser.class); EasyMock.expect(FilterInfoParser.parse(EasyMock.anyObject(SourceKey.class), EasyMock.anyObject(FilterInfoBean.class))) .andReturn(new SwiftDetailFilterInfo<Set<Double>>(new ColumnKey("a"), Collections.singleton((double) 1), SwiftDetailFilterType.IN)) .anyTimes(); PowerMock.replay(FilterInfoParser.class); 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.HAVING_FILTER, infoList.get(0).getType()); HavingFilterQueryInfo info = (HavingFilterQueryInfo) infoList.get(0); assertEquals(1, info.getMatchFilterList().size()); DetailBasedMatchFilter filter = (DetailBasedMatchFilter) info.getMatchFilterList().get(0); }
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; }    }