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));
}
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();
});
}
Aggregations