Search in sources :

Example 6 with ISqlStyle

use of org.eclipse.scout.rt.server.jdbc.style.ISqlStyle in project scout.rt by eclipse.

the class StatementProcessorCreateSqlDumpTest method runDump.

private void runDump(String expected, StatementType type, String statement) {
    ISqlStyle style = Mockito.mock(ISqlStyle.class);
    Mockito.when(style.buildBindFor(23, null)).thenReturn(new SqlBind(4, 23));
    Mockito.when(style.toPlainText(23)).thenReturn("23");
    Mockito.when(style.buildBindFor("lorem", null)).thenReturn(new SqlBind(1, "lorem"));
    Mockito.when(style.toPlainText("lorem")).thenReturn("'lorem'");
    ISqlService callerService = Mockito.mock(ISqlService.class);
    Mockito.when(callerService.getSqlStyle()).thenReturn(style);
    Object[] bindBases = new Object[] { new NVPair("myKey", 23), new NVPair("myText", "lorem") };
    P_StatementProcessor_UnderTest statementProcessor = new P_StatementProcessor_UnderTest(callerService, statement, bindBases);
    String dump = statementProcessor.getDump(type);
    assertEquals(type.name() + " dump", expected, dump);
}
Also used : SqlBind(org.eclipse.scout.rt.server.jdbc.SqlBind) ISqlStyle(org.eclipse.scout.rt.server.jdbc.style.ISqlStyle) ISqlService(org.eclipse.scout.rt.server.jdbc.ISqlService) NVPair(org.eclipse.scout.rt.platform.holders.NVPair)

Aggregations

ISqlStyle (org.eclipse.scout.rt.server.jdbc.style.ISqlStyle)6 SQLException (java.sql.SQLException)3 SqlBind (org.eclipse.scout.rt.server.jdbc.SqlBind)3 ResultSetMetaData (java.sql.ResultSetMetaData)2 ProcessingException (org.eclipse.scout.rt.platform.exception.ProcessingException)2 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 ArrayList (java.util.ArrayList)1 PlatformExceptionTranslator (org.eclipse.scout.rt.platform.exception.PlatformExceptionTranslator)1 NVPair (org.eclipse.scout.rt.platform.holders.NVPair)1 ISqlService (org.eclipse.scout.rt.server.jdbc.ISqlService)1