AggregationDistinctQueryMetaData { public int getAggregationDistinctColumnIndex(final int derivedSumIndex) { for (Entry<Integer, Integer> entry : aggregationDistinctColumnIndexAndSumColumnIndexes.entrySet()) { if (entry.getValue().equals(derivedSumIndex)) { return entry.getKey(); } } throw new ShardingException("Can not get aggregation distinct column index."); } AggregationDistinctQueryMetaData(final Collection<AggregationDistinctSelectItem> aggregationDistinctSelectItems, final QueryResultMetaData queryResultMetaData); boolean isAggregationDistinctColumnIndex(final int columnIndex); boolean isAggregationDistinctColumnLabel(final String columnLabel); AggregationType getAggregationType(final int distinctColumnIndex); boolean isDerivedCountColumnIndex(final int columnIndex); boolean isDerivedSumColumnIndex(final int columnIndex); int getAggregationDistinctColumnIndex(final int derivedSumIndex); int getAggregationDistinctColumnIndex(final String distinctColumnLabel); String getAggregationDistinctColumnLabel(final int distinctColumnIndex);  }
@Test public void assertGetAggregationDistinctColumnIndexByColumnLabel() { int actual = distinctQueryMetaData.getAggregationDistinctColumnIndex("a"); assertThat(actual, is(2)); }
@Test(expected = ShardingException.class) public void assertGetAggregationDistinctColumnIndexByColumnLabelWithException() { int actual = distinctQueryMetaData.getAggregationDistinctColumnIndex("f"); assertThat(actual, is(2)); }
@Test public void assertGetAggregationDistinctColumnIndexBySumIndex() { int actual = distinctQueryMetaData.getAggregationDistinctColumnIndex(4); assertThat(actual, is(2)); }
@Test(expected = ShardingException.class) public void assertGetAggregationDistinctColumnIndexBySumIndexWithException() { int actual = distinctQueryMetaData.getAggregationDistinctColumnIndex(0); assertThat(actual, is(2)); }