Search in sources :

Example 41 with Something

use of org.jdbi.v3.core.Something in project jdbi by jdbi.

the class TestBatching method testBooleanReturn.

@Test
public void testBooleanReturn() throws Exception {
    BooleanBatchDao dao = handle.attach(BooleanBatchDao.class);
    assertThat(dao.insert(new Something(1, "foo"), new Something(2, "bar"))).containsExactly(true, true);
    assertThat(dao.update(new Something(1, "baz"), new Something(3, "buz"))).containsExactly(true, false);
}
Also used : Something(org.jdbi.v3.core.Something) Test(org.junit.Test)

Example 42 with Something

use of org.jdbi.v3.core.Something in project jdbi by jdbi.

the class TestBeanBinder method testInsert.

@Test
public void testInsert() throws Exception {
    Spiffy s = handle.attach(Spiffy.class);
    s.insert(new Something(2, "Bean"));
    String name = handle.createQuery("select name from something where id = 2").mapTo(String.class).findOnly();
    assertThat(name).isEqualTo("Bean");
}
Also used : Something(org.jdbi.v3.core.Something) Test(org.junit.Test)

Example 43 with Something

use of org.jdbi.v3.core.Something in project jdbi by jdbi.

the class TestBeanBinder method testRead.

@Test
public void testRead() throws Exception {
    Spiffy s = handle.attach(Spiffy.class);
    handle.execute("insert into something (id, name) values (17, 'Phil')");
    Something phil = s.findByEqualsOnBothFields(new Something(17, "Phil"));
    assertThat(phil.getName()).isEqualTo("Phil");
}
Also used : Something(org.jdbi.v3.core.Something) Test(org.junit.Test)

Example 44 with Something

use of org.jdbi.v3.core.Something in project jdbi by jdbi.

the class TestBindAutomaticNames method testNoAnnotation.

@Test
public void testNoAnnotation() throws Exception {
    Spiffy spiffy = dbRule.getSharedHandle().attach(Spiffy.class);
    Something s = spiffy.findByIdNoAnnotation(7);
    assertThat(s.getName()).isEqualTo("Tim");
}
Also used : Something(org.jdbi.v3.core.Something) Test(org.junit.Test)

Example 45 with Something

use of org.jdbi.v3.core.Something in project jdbi by jdbi.

the class TestBindBean method testBindBean.

@Test
public void testBindBean() {
    handle.execute("insert into something (id, name) values (1, 'Alice')");
    assertThat(dao.getName(1)).isEqualTo("Alice");
    dao.update(new Something(1, "Alicia"));
    assertThat(dao.getName(1)).isEqualTo("Alicia");
}
Also used : Something(org.jdbi.v3.core.Something) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)170 Something (org.jdbi.v3.core.Something)123 Handle (org.jdbi.v3.core.Handle)80 SomethingMapper (org.jdbi.v3.core.mapper.SomethingMapper)17 Before (org.junit.Before)11 ArrayList (java.util.ArrayList)6 Jdbi (org.jdbi.v3.core.Jdbi)6 HashMap (java.util.HashMap)5 Map (java.util.Map)5 GenericType (org.jdbi.v3.core.generic.GenericType)5 List (java.util.List)4 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)4 H2DatabaseRule (org.jdbi.v3.core.rule.H2DatabaseRule)4 Rule (org.junit.Rule)4 Connection (java.sql.Connection)3 LinkedHashMap (java.util.LinkedHashMap)3 Collector (java.util.stream.Collector)3 Collectors.toList (java.util.stream.Collectors.toList)3 JdbcDataSource (org.h2.jdbcx.JdbcDataSource)3 NoSuchMapperException (org.jdbi.v3.core.mapper.NoSuchMapperException)3