@@ -0,0 +1,3504 @@
+/*%0A * Copyright 2016-2018 shardingsphere.io.%0A * %3Cp%3E%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A * %3C/p%3E%0A */%0A%0Apackage io.shardingsphere.core.executor;%0A%0Aimport io.shardingsphere.core.constant.SQLType;%0Aimport io.shardingsphere.core.constant.transaction.TransactionType;%0Aimport io.shardingsphere.core.executor.sql.SQLExecuteCallback;%0Aimport io.shardingsphere.core.executor.sql.StatementExecuteUnit;%0Aimport io.shardingsphere.core.routing.SQLExecutionUnit;%0Aimport io.shardingsphere.core.routing.SQLUnit;%0Aimport io.shardingsphere.transaction.TransactionTypeHolder;%0Aimport io.shardingsphere.transaction.manager.base.executor.SagaSQLExeucteCallback;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.mockito.Mock;%0Aimport org.mockito.junit.MockitoJUnitRunner;%0A%0Aimport java.sql.PreparedStatement;%0Aimport java.sql.SQLException;%0Aimport java.sql.Statement;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport static org.hamcrest.CoreMatchers.is;%0Aimport static org.junit.Assert.assertThat;%0Aimport static org.mockito.Mockito.verify;%0A%0A@RunWith(MockitoJUnitRunner.class)%0Apublic class SQLExeucteCallbackFactoryTest %7B%0A    %0A    @Mock%0A    private PreparedStatement preparedStatement;%0A    %0A    private final String dsName = %22ds%22;%0A    %0A    private final String sql = %22SELECT now()%22;%0A    %0A    private final StatementExecuteUnit unit = new StatementExecuteUnit() %7B%0A        @Override%0A        public SQLExecutionUnit getSqlExecutionUnit() %7B%0A            return new SQLExecutionUnit(dsName, new SQLUnit(sql, new ArrayList%3CList%3CObject%3E%3E()));%0A        %7D%0A    %0A        @Override%0A        public Statement getStatement() %7B%0A            return preparedStatement;%0A        %7D%0A    %7D;%0A    %0A    @Test%0A    public void assertGetSagaSQLExecuteCallback() %7B%0A        TransactionTypeHolder.set(TransactionType.BASE);%0A        SQLExecuteCallback sqlExecuteCallback = SQLExecuteCallbackFactory.getPreparedUpdateSQLExecuteCallback(SQLType.DML, false, null);%0A        assertThat(sqlExecuteCallback instanceof SagaSQLExeucteCallback, is(true));%0A    %7D%0A    %0A    @Test%0A    public void assertGetPreparedUpdateSQLExecuteCallback() throws SQLException %7B%0A        SQLExecuteCallback sqlExecuteCallback = SQLExecuteCallbackFactory.getPreparedUpdateSQLExecuteCallback(SQLType.DML, true, null);%0A        sqlExecuteCallback.execute(unit);%0A        verify(preparedStatement).executeUpdate();%0A    %7D%0A    %0A    @Test%0A    public void assertGetPreparedQuerySQLExecuteCallback() throws SQLException %7B%0A        SQLExecuteCallback sqlExecuteCallback = SQLExecuteCallbackFactory.getPreparedQuerySQLExecuteCallback(SQLType.DQL, true, null);%0A        sqlExecuteCallback.execute(unit);%0A        verify(preparedStatement).executeQuery();%0A    %7D%0A    %0A    @Test%0A    public void assertGetPreparedSQLExecuteCallback() throws SQLException %7B%0A        SQLExecuteCallback sqlExecuteCallback = SQLExecuteCallbackFactory.getPreparedSQLExecuteCallback(SQLType.DQL, true, null);%0A        sqlExecuteCallback.execute(unit);%0A        verify(preparedStatement).execute();%0A    %7D%0A%7D%0A

add SQLExecuteCallbackFactory unit test