/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.
 */

package org.apache.shardingsphere.core.rewrite.builder;

import com.google.common.base.Optional;
import org.apache.shardingsphere.core.optimize.statement.sharding.dml.select.Pagination;
import org.apache.shardingsphere.core.optimize.statement.sharding.dml.select.ShardingSelectOptimizedStatement;
import org.apache.shardingsphere.core.route.SQLRouteResult;
import org.apache.shardingsphere.core.route.type.RoutingResult;
import org.hamcrest.core.AnyOf;
import org.junit.Before;
import org.junit.Test;

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

public final class BaseParameterBuilderTest {
    
    private BaseParameterBuilder baseParameterBuilder;
    
    @Before
    public void setUp() {
        baseParameterBuilder = new BaseParameterBuilder()
    }
    
    private SQLRouteResult createSQLRouteResult() {
        Pagination pagination = mock(Pagination.class);
        when(pagination.getOffsetParameterIndex()).thenReturn(Optional.of(0));
        when(pagination.getRowCountParameterIndex()).thenReturn(Optional.of(1));
        when(pagination.getRevisedRowCount(any(ShardingSelectOptimizedStatement.class))).thenReturn(6);
        ShardingSelectOptimizedStatement optimizedStatement = mock(ShardingSelectOptimizedStatement.class);
        when(optimizedStatement.getPagination()).thenReturn(pagination);
        SQLRouteResult result = new SQLRouteResult(optimizedStatement);
        result.setRoutingResult(new RoutingResult());
        return result;
    }
    
    @Test
    public void assertGetParameters() {
    }
    
    @Test
    public void assertGetParameters1() {
    }
    
    @Test
    public void assertGetOriginalParameters() {
    }
    
    @Test
    public void assertGetAddedIndexAndParameters() {
    }
    
    @Test
    public void assertGetReplacedIndexAndParameters() {
    }
}

@@ -1232,27 +1232,57 @@
 org.
-hamcrest.core.AnyOf
+apache.shardingsphere.core.route.type.RoutingUnit
 ;%0Aim
@@ -1328,16 +1328,213 @@
 .Test;%0A%0A
+import java.util.Arrays;%0Aimport java.util.Collections;%0Aimport java.util.LinkedHashMap;%0Aimport java.util.Map;%0A%0Aimport static org.hamcrest.CoreMatchers.is;%0Aimport static org.junit.Assert.assertThat;%0A
 import s
@@ -1859,17 +1859,173 @@
 Builder(
-)
+Arrays.%3CObject%3EasList(1, 2, 1, 5), createSQLRouteResult());%0A        baseParameterBuilder.getAddedIndexAndParameters().putAll(Collections.singletonMap(4, 7));
 %0A    %7D%0A 
@@ -2210,17 +2210,17 @@
 onal.of(
-0
+2
 ));%0A    
@@ -2291,17 +2291,17 @@
 onal.of(
-1
+3
 ));%0A    
@@ -2799,285 +2799,882 @@
     
-%7D%0A
     
-%0A    @Test%0A    public void assertGetParameters1() %7B%0A    %7D%0A    %0A    @Test%0A    public void assertGetOriginalParameters() %7B%0A    %7D%0A    %0A    @Test%0A    public void assertGetAddedIndexAndParameters() %7B%0A    %7D%0A    %0A    @Test%0A    public void assertGetReplacedIndexAndParameters() %7B
+assertThat(baseParameterBuilder.getParameters(), is(Arrays.%3CObject%3EasList(1, 2, 0, 6, 7)));%0A        assertThat(baseParameterBuilder.getParameters(mock(RoutingUnit.class)), is(Arrays.%3CObject%3EasList(1, 2, 0, 6, 7)));%0A    %7D%0A    %0A    @Test%0A    public void assertGetOriginalParameters() %7B%0A        assertThat(baseParameterBuilder.getOriginalParameters(), is(Arrays.%3CObject%3EasList(1, 2, 1, 5)));%0A    %7D%0A    %0A    @Test%0A    public void assertGetAddedIndexAndParameters() %7B%0A        assertThat(baseParameterBuilder.getAddedIndexAndParameters(), is(Collections.%3CInteger, Object%3EsingletonMap(4, 7)));%0A    %7D%0A    %0A    @Test%0A    public void assertGetReplacedIndexAndParameters() %7B%0A        Map%3CInteger, Object%3E expected = new LinkedHashMap%3C%3E();%0A        expected.put(2, 0);%0A        expected.put(3, 6);%0A        assertThat(baseParameterBuilder.getReplacedIndexAndParameters(), is(expected));
 %0A   

add test case for BaseParameterBuilderTest