use of org.jdbi.v3.core.Something in project jdbi by jdbi.
the class TestScript method testFuzzyScript.
@Test
public void testFuzzyScript() throws Exception {
Handle h = dbRule.openHandle();
Script script = h.createScript(getResourceOnClasspath("script/fuzzy-script.sql"));
script.executeAsSeparateStatements();
List<Map<String, Object>> rows = h.select("select id, name from something order by id").mapToMap().list();
assertThat(rows).isEqualTo(ImmutableList.of(ImmutableMap.of("id", 1L, "name", "eric"), ImmutableMap.of("id", 2L, "name", "sally;ann"), ImmutableMap.of("id", 3L, "name", "bob"), ImmutableMap.of("id", 12L, "name", "sally;ann;junior")));
}
use of org.jdbi.v3.core.Something in project jdbi by jdbi.
the class TestStatements method testSimpleUpdate.
@Test
public void testSimpleUpdate() throws Exception {
h.execute("insert into something (id, name) values (1, 'eric')");
h.execute("update something set name = 'cire' where id = 1");
Something eric = h.createQuery("select * from something where id = 1").mapToBean(Something.class).list().get(0);
assertThat(eric.getName()).isEqualTo("cire");
}
use of org.jdbi.v3.core.Something in project jdbi by jdbi.
the class TestStatements method testUpdate.
@Test
public void testUpdate() throws Exception {
h.execute("insert into something (id, name) values (1, 'eric')");
h.createUpdate("update something set name = 'ERIC' where id = 1").execute();
Something eric = h.createQuery("select * from something where id = 1").mapToBean(Something.class).list().get(0);
assertThat(eric.getName()).isEqualTo("ERIC");
}
use of org.jdbi.v3.core.Something in project jdbi by jdbi.
the class TestClasspathSqlLocator method testPositionalParamsInPrepared.
@Test
public void testPositionalParamsInPrepared() throws Exception {
Handle h = dbRule.openHandle();
h.execute(findSqlOnClasspath("insert-id-name-positional"), 3, "Tip");
assertThat(h.select("select name from something").mapTo(String.class).list()).hasSize(1);
}
use of org.jdbi.v3.core.Something in project jdbi by jdbi.
the class TestClasspathSqlLocator method testCommentsInExternalSql.
@Test
public void testCommentsInExternalSql() throws Exception {
Handle h = dbRule.openHandle();
h.execute(findSqlOnClasspath("insert-eric-with-comments"));
assertThat(h.select("select name from something").mapTo(String.class).list()).hasSize(1);
}
Aggregations