use of org.jdbi.v3.core.Something in project jdbi by jdbi.
the class TestBindExpression method testExpression.
@Test
public void testExpression() throws Exception {
DB db = dbRule.getSharedHandle().attach(DB.class);
db.insert(new Something(1, "syrup"), new Something(2, "whipped cream"));
Something with_syrup = db.findByBreakfast(new Breakfast());
assertThat(with_syrup).isEqualTo(new Something(1, "syrup"));
}
use of org.jdbi.v3.core.Something in project jdbi by jdbi.
the class TestCollectorFactory method testWithSqlObjectSetReturnValue.
@Test
public void testWithSqlObjectSetReturnValue() throws Exception {
Dao dao = dbRule.getJdbi().onDemand(Dao.class);
dao.insert(new Something(1, "Coda"));
dao.insert(new Something(2, "Brian"));
SortedSet<String> rs = dao.findAllAsSet();
assertThat(rs).containsExactly("Brian", "Coda");
}
use of org.jdbi.v3.core.Something in project jdbi by jdbi.
the class TestConsumer method testReturnStream.
@Test
public void testReturnStream() throws Exception {
Something one = new Something(3, "foo");
Something two = new Something(4, "bar");
Something thr = new Something(5, "baz");
Spiffy dao = dbRule.getJdbi().open().attach(Spiffy.class);
dao.insert(one);
dao.insert(thr);
dao.insert(two);
List<Something> results = new ArrayList<>();
dao.forEach(results::add);
assertThat(results).containsExactly(thr, two, one);
}
use of org.jdbi.v3.core.Something in project jdbi by jdbi.
the class TestCustomBinder method testFoo.
@Test
public void testFoo() throws Exception {
dbRule.getSharedHandle().execute("insert into something (id, name) values (2, 'Martin')");
dbRule.getJdbi().useExtension(Spiffy.class, spiffy -> {
Something s = spiffy.findSame(new Something(2, "Unknown"));
assertThat(s.getName()).isEqualTo("Martin");
});
}
use of org.jdbi.v3.core.Something in project jdbi by jdbi.
the class TestDefineListParameter method testEmptyList.
@Test(expected = IllegalArgumentException.class)
public void testEmptyList() {
TestDao testDao = handle.attach(TestDao.class);
List<String> noColumns = new ArrayList<>();
Something something = new Something(1, "Some Pig");
testDao.insert("test", noColumns, something);
}
Aggregations