@Test public void getQueryResult() { GroupByInfo groupByInfo = mock(GroupByInfo.class); MetricInfo metricInfo = mock(MetricInfo.class); mockStatic(NodeGroupByUtils.class); Iterator<GroupPage> pageItr = mock(Iterator.class); when(NodeGroupByUtils.groupBy(groupByInfo, metricInfo)).thenReturn(pageItr); when(pageItr.hasNext()).thenReturn(true, false); GroupPage page = mock(GroupPage.class); when(pageItr.next()).thenReturn(page); QueryResultSet<GroupPage> resultSet = new GroupSegmentQuery(groupByInfo, metricInfo).getQueryResult(); assertThat(resultSet.getFetchSize()).isEqualTo(0); assertThat(resultSet.hasNextPage()).isEqualTo(true); assertThat(resultSet.hasNextPage()).isEqualTo(false); assertThat(resultSet.getPage()).isEqualTo(page); }
@Override public QueryResultSet<GroupPage> getQueryResult() { Iterator<GroupPage> iterator = NodeGroupByUtils.groupBy(groupByInfo, metricInfo); return new IteratorAdapter<GroupPage>(iterator, groupByInfo.getFetchSize()); }
GroupSegmentQuery implements Query<QueryResultSet<GroupPage>> { @Override public QueryResultSet<GroupPage> getQueryResult() { Iterator<GroupPage> iterator = NodeGroupByUtils.groupBy(groupByInfo, metricInfo); return new IteratorAdapter<GroupPage>(iterator, groupByInfo.getFetchSize()); } }
GroupSegmentQuery implements Query<QueryResultSet<GroupPage>> { @Override public QueryResultSet<GroupPage> getQueryResult() { Iterator<GroupPage> iterator = NodeGroupByUtils.groupBy(groupByInfo, metricInfo); return new IteratorAdapter<GroupPage>(iterator, groupByInfo.getFetchSize()); } GroupSegmentQuery(GroupByInfo groupByInfo, MetricInfo metricInfo); }
GroupSegmentQuery implements Query<QueryResultSet<GroupPage>> { @Override public QueryResultSet<GroupPage> getQueryResult() { Iterator<GroupPage> iterator = NodeGroupByUtils.groupBy(groupByInfo, metricInfo); return new IteratorAdapter<GroupPage>(iterator, groupByInfo.getFetchSize()); } GroupSegmentQuery(GroupByInfo groupByInfo, MetricInfo metricInfo); @Override QueryResultSet<GroupPage> getQueryResult(); }
GroupSegmentQuery implements Query<QueryResultSet<GroupPage>> { @Override public QueryResultSet<GroupPage> getQueryResult() { Iterator<GroupPage> iterator = NodeGroupByUtils.groupBy(groupByInfo, metricInfo); return new IteratorAdapter<GroupPage>(iterator, groupByInfo.getFetchSize()); } GroupSegmentQuery(GroupByInfo groupByInfo, MetricInfo metricInfo); @Override QueryResultSet<GroupPage> getQueryResult();  }