Search in sources :

Example 6 with ExpandedStatement

use of org.eclipse.hono.service.base.jdbc.store.Statement.ExpandedStatement in project hono by eclipse.

the class QueryTest method testExtraParams.

/**
 * Test providing additional named parameters, which are not referenced in the statement.
 */
@Test
public void testExtraParams() {
    final ExpandedStatement expanded = Statement.statement("select * from table where foo=:foo and bar=:bar").expand(params -> {
        // not used
        params.put("foobarbaz", true);
        params.put("foo", 1);
        params.put("bar", "baz");
    });
    assertEquals("select * from table where foo=? and bar=?", expanded.getSql());
    assertArrayEquals(new Object[] { 1, "baz" }, expanded.getParameters());
}
Also used : ExpandedStatement(org.eclipse.hono.service.base.jdbc.store.Statement.ExpandedStatement) Test(org.junit.jupiter.api.Test)

Example 7 with ExpandedStatement

use of org.eclipse.hono.service.base.jdbc.store.Statement.ExpandedStatement in project hono by eclipse.

the class QueryTest method testNoParams.

/**
 * Test a statement with no parameters.
 */
@Test
public void testNoParams() {
    final ExpandedStatement expanded = Statement.statement("select 1").expand(Collections.emptyMap());
    assertEquals("select 1", expanded.getSql());
    assertArrayEquals(new Object[] {}, expanded.getParameters());
}
Also used : ExpandedStatement(org.eclipse.hono.service.base.jdbc.store.Statement.ExpandedStatement) Test(org.junit.jupiter.api.Test)

Aggregations

ExpandedStatement (org.eclipse.hono.service.base.jdbc.store.Statement.ExpandedStatement)7 Test (org.junit.jupiter.api.Test)6 HashMap (java.util.HashMap)2 Span (io.opentracing.Span)1 SpanContext (io.opentracing.SpanContext)1 Tracer (io.opentracing.Tracer)1 Future (io.vertx.core.Future)1 Json (io.vertx.core.json.Json)1 JsonObject (io.vertx.core.json.JsonObject)1 JDBCClient (io.vertx.ext.jdbc.JDBCClient)1 ResultSet (io.vertx.ext.sql.ResultSet)1 SQLOperations (io.vertx.ext.sql.SQLOperations)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 AbstractStore (org.eclipse.hono.service.base.jdbc.store.AbstractStore)1 SQL (org.eclipse.hono.service.base.jdbc.store.SQL)1 Statement (org.eclipse.hono.service.base.jdbc.store.Statement)1 StatementConfiguration (org.eclipse.hono.service.base.jdbc.store.StatementConfiguration)1