/*
 * Copyright 2016-2018 shardingsphere.io.
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * </p>
 */

package io.shardingsphere.core.executor.sql.execute.result;

import io.shardingsphere.core.merger.QueryResult;
import lombok.SneakyThrows;
import org.junit.Before;
import org.junit.Test;

import java.util.Collection;
import java.util.LinkedList;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class AggregationDistinctQueryResultTest {
    
    private AggregationDistinctQueryResult aggregationDistinctQueryResult;
    
    @Before
    public void setUp() {
        
    }
    
    @SneakyThrows
    private Collection<QueryResult> getQueryResults() {
        Collection<QueryResult> result = new LinkedList<>();
        for (int i = 1; i <= 2; i++) {
            QueryResult queryResult = mock(QueryResult.class);
            when(queryResult.next()).thenReturn(true).thenReturn(false);
            when(queryResult.getColumnCount()).thenReturn(3);
            when(queryResult.getColumnLabel(1)).thenReturn("order_id");
            when(queryResult.getColumnLabel(2)).thenReturn("order_id");
            when(queryResult.getColumnLabel(3)).thenReturn("order_id");
            when(queryResult.getValue(1, Object.class)).thenReturn(10 * i);
            when(queryResult.getValue(2, Object.class)).thenReturn(10 * i);
            when(queryResult.getValue(3, Object.class)).thenReturn(10 * i);
            result.add(queryResult);
            result.add(queryResult);
        }
        return result;
    }
    
    @Test
    public void testDivide() {
    }
    
    @Test
    public void testGetValue() {
    }
    
    @Test
    public void testGetValue1() {
    }
    
    @Test
    public void testGetCalendarValue() {
    }
    
    @Test
    public void testGetCalendarValue1() {
    }
    
    @Test
    public void testGetInputStream() {
    }
    
    @Test
    public void testGetInputStream1() {
    }
    
    @Test
    public void testWasNull() {
    }
    
    @Test
    public void testGetColumnCount() {
    }
    
    @Test
    public void testGetColumnLabel() {
    }
    
    @Test
    public void testGetColumnIndex() {
    }
}

@@ -685,49 +685,417 @@
 ort 
-io.shardingsphere.core.merger.QueryResult
+com.google.common.base.Optional;%0Aimport com.google.common.collect.HashMultimap;%0Aimport com.google.common.collect.Multimap;%0Aimport io.shardingsphere.core.constant.AggregationType;%0Aimport io.shardingsphere.core.merger.QueryResult;%0Aimport io.shardingsphere.core.parsing.parser.context.selectitem.AggregationDistinctSelectItem;%0Aimport io.shardingsphere.core.parsing.parser.context.selectitem.AggregationSelectItem
 ;%0Aim
@@ -2002,32 +2002,25 @@
 thenReturn(%22
-order_id
+c
 %22);%0A        
@@ -2067,32 +2067,25 @@
 thenReturn(%22
-order_id
+a
 %22);%0A        
@@ -2370,32 +2370,32 @@
 d(queryResult);%0A
-
         %7D%0A      
@@ -2414,32 +2414,1195 @@
 ult;%0A    %7D%0A    %0A
+    private Collection%3CAggregationDistinctSelectItem%3E getAggregationDistinctSelectItems() %7B%0A        Collection%3CAggregationDistinctSelectItem%3E result = new LinkedList%3C%3E();%0A        AggregationDistinctSelectItem distinctCountSelectItem = new AggregationDistinctSelectItem(AggregationType.COUNT, %22(DISTINCT order_id)%22, Optional.of(%22c%22), %22order_id%22);%0A        AggregationDistinctSelectItem distinctAvgSelectItem = new AggregationDistinctSelectItem(AggregationType.AVG, %22(DISTINCT order_id)%22, Optional.of(%22a%22), %22order_id%22);%0A        distinctAvgSelectItem.getDerivedAggregationSelectItems().add(new AggregationSelectItem(AggregationType.COUNT, %22(DISTINCT order_id)%22, Optional.of(%22AVG_DERIVED_COUNT_0%22)));%0A        distinctAvgSelectItem.getDerivedAggregationSelectItems().add(new AggregationSelectItem(AggregationType.SUM, %22(DISTINCT order_id)%22, Optional.of(%22AVG_DERIVED_SUM_0%22)));%0A        result.add(distinctCountSelectItem);%0A        result.add(distinctAvgSelectItem);%0A        Multimap%3CString, Integer%3E columnLabelAndIndexMap = HashMultimap.create();%0A        columnLabelAndIndexMap.put(%22c%22, 1);%0A        columnLabelAndIndexMap.put(%22a%22, 2);%0A        return result;%0A    %7D%0A    %0A
     @Test%0A    pu

add getAggregationDistinctSelectItems()