Search in sources :

Example 1 with AgnosticResultSetImpl

use of com.palantir.nexus.db.sql.AgnosticResultSetImpl in project atlasdb by palantir.

the class PostgresDdlTableTest method setUpSqlConnection.

private SqlConnection setUpSqlConnection(Long lastVacuumTimestamp, Long currentTimestamp) {
    SqlConnection sqlConnection = mock(SqlConnection.class);
    when(connectionSupplier.get()).thenReturn(sqlConnection);
    List<List<Object>> selectResults = new ArrayList<>();
    selectResults.add(Arrays.asList(new Object[] { lastVacuumTimestamp, currentTimestamp }));
    Mockito.when(sqlConnection.selectResultSetUnregisteredQuery(startsWith("SELECT FLOOR"), any())).thenReturn(new AgnosticResultSetImpl(selectResults, DBType.POSTGRESQL, // upper-case and lower-case, as postgres allows the query to have either of them.
    new ImmutableMap.Builder<String, Integer>().put("last", 0).put("LAST", 0).put("current", 1).put("CURRENT", 1).build()));
    return sqlConnection;
}
Also used : ArrayList(java.util.ArrayList) SqlConnection(com.palantir.nexus.db.sql.SqlConnection) ArrayList(java.util.ArrayList) List(java.util.List) ImmutableMap(com.google.common.collect.ImmutableMap) AgnosticResultSetImpl(com.palantir.nexus.db.sql.AgnosticResultSetImpl)

Aggregations

ImmutableMap (com.google.common.collect.ImmutableMap)1 AgnosticResultSetImpl (com.palantir.nexus.db.sql.AgnosticResultSetImpl)1 SqlConnection (com.palantir.nexus.db.sql.SqlConnection)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1