Search in sources :

Example 1 with OracleInsertExecutor

use of io.seata.rm.datasource.exec.oracle.OracleInsertExecutor in project seata by seata.

the class AbstractDMLBaseExecutorTest method testOnlySupportMysqlWhenUseMultiPk.

@Test
public void testOnlySupportMysqlWhenUseMultiPk() {
    Mockito.when(connectionProxy.getContext()).thenReturn(new ConnectionContext());
    PreparedStatementProxy statementProxy = Mockito.mock(PreparedStatementProxy.class);
    Mockito.when(statementProxy.getConnectionProxy()).thenReturn(connectionProxy);
    StatementCallback statementCallback = Mockito.mock(StatementCallback.class);
    SQLInsertRecognizer sqlInsertRecognizer = Mockito.mock(SQLInsertRecognizer.class);
    TableMeta tableMeta = Mockito.mock(TableMeta.class);
    executor = Mockito.spy(new OracleInsertExecutor(statementProxy, statementCallback, sqlInsertRecognizer));
    Mockito.when(executor.getDbType()).thenReturn(JdbcConstants.ORACLE);
    Mockito.doReturn(tableMeta).when(executor).getTableMeta();
    Mockito.when(tableMeta.getPrimaryKeyOnlyName()).thenReturn(Arrays.asList("id", "userCode"));
    Assertions.assertThrows(NotSupportYetException.class, () -> executor.executeAutoCommitFalse(null));
}
Also used : OracleInsertExecutor(io.seata.rm.datasource.exec.oracle.OracleInsertExecutor) ConnectionContext(io.seata.rm.datasource.ConnectionContext) TableMeta(io.seata.rm.datasource.sql.struct.TableMeta) PreparedStatementProxy(io.seata.rm.datasource.PreparedStatementProxy) SQLInsertRecognizer(io.seata.sqlparser.SQLInsertRecognizer) Test(org.junit.jupiter.api.Test)

Example 2 with OracleInsertExecutor

use of io.seata.rm.datasource.exec.oracle.OracleInsertExecutor in project seata by seata.

the class OracleInsertExecutorTest method testStatement_pkValueByAuto_NotSupportYetException.

@Test
public void testStatement_pkValueByAuto_NotSupportYetException() throws Exception {
    mockInsertColumns();
    mockStatementInsertRows();
    statementProxy = mock(StatementProxy.class);
    when(statementProxy.getConnectionProxy()).thenReturn(connectionProxy);
    when(connectionProxy.getDbType()).thenReturn(JdbcConstants.ORACLE);
    insertExecutor = Mockito.spy(new OracleInsertExecutor(statementProxy, statementCallback, sqlInsertRecognizer));
    doReturn(tableMeta).when(insertExecutor).getTableMeta();
    Map<String, ColumnMeta> map = new HashMap<>();
    map.put(ID_COLUMN, mock(ColumnMeta.class));
    doReturn(map).when(tableMeta).getPrimaryKeyMap();
    ResultSet rs = mock(ResultSet.class);
    doReturn(rs).when(statementProxy).getGeneratedKeys();
    doReturn(false).when(rs).next();
    Assertions.assertThrows(NotSupportYetException.class, () -> {
        insertExecutor.getGeneratedKeys();
    });
    doReturn(pkIndexMap).when(insertExecutor).getPkIndex();
    Assertions.assertThrows(NotSupportYetException.class, () -> {
        insertExecutor.getPkValuesByColumn();
    });
}
Also used : ColumnMeta(io.seata.rm.datasource.sql.struct.ColumnMeta) HashMap(java.util.HashMap) OracleInsertExecutor(io.seata.rm.datasource.exec.oracle.OracleInsertExecutor) StatementProxy(io.seata.rm.datasource.StatementProxy) PreparedStatementProxy(io.seata.rm.datasource.PreparedStatementProxy) ResultSet(java.sql.ResultSet) Test(org.junit.jupiter.api.Test)

Aggregations

PreparedStatementProxy (io.seata.rm.datasource.PreparedStatementProxy)2 OracleInsertExecutor (io.seata.rm.datasource.exec.oracle.OracleInsertExecutor)2 Test (org.junit.jupiter.api.Test)2 ConnectionContext (io.seata.rm.datasource.ConnectionContext)1 StatementProxy (io.seata.rm.datasource.StatementProxy)1 ColumnMeta (io.seata.rm.datasource.sql.struct.ColumnMeta)1 TableMeta (io.seata.rm.datasource.sql.struct.TableMeta)1 SQLInsertRecognizer (io.seata.sqlparser.SQLInsertRecognizer)1 ResultSet (java.sql.ResultSet)1 HashMap (java.util.HashMap)1