use of org.jdbi.v3.core.SampleBean in project jdbi by jdbi.
the class FieldMapperTest method shouldNotThrowOnMismatchedColumns.
@Test
public void shouldNotThrowOnMismatchedColumns() throws Exception {
mockColumns("longField", "extraColumn");
Long expected = 666L;
when(resultSet.getLong(1)).thenReturn(expected);
when(resultSet.getString(2)).thenReturn("foo");
SampleBean sampleBean = mapper.map(resultSet, ctx);
assertThat(sampleBean.getLongField()).isEqualTo(expected);
}
use of org.jdbi.v3.core.SampleBean in project jdbi by jdbi.
the class FieldMapperTest method shouldHandleEmptyResult.
@Test
public void shouldHandleEmptyResult() throws Exception {
mockColumns();
SampleBean sampleBean = mapper.map(resultSet, ctx);
assertThat(sampleBean).isNotNull();
}
use of org.jdbi.v3.core.SampleBean in project jdbi by jdbi.
the class FieldMapperTest method shouldSetValuesOnAllFieldAccessTypes.
@Test
public void shouldSetValuesOnAllFieldAccessTypes() throws Exception {
mockColumns("longField", "protectedStringField", "packagePrivateIntField", "privateBigDecimalField");
Long aLongVal = 100L;
String aStringVal = "something";
int aIntVal = 1;
BigDecimal aBigDecimal = BigDecimal.TEN;
when(resultSet.getLong(1)).thenReturn(aLongVal);
when(resultSet.getString(2)).thenReturn(aStringVal);
when(resultSet.getInt(3)).thenReturn(aIntVal);
when(resultSet.getBigDecimal(4)).thenReturn(aBigDecimal);
when(resultSet.wasNull()).thenReturn(false);
SampleBean sampleBean = mapper.map(resultSet, ctx);
assertThat(sampleBean.getLongField()).isEqualTo(aLongVal);
assertThat(sampleBean.getPrivateBigDecimalField()).isEqualTo(aBigDecimal);
assertThat(sampleBean.getPackagePrivateIntField()).isEqualTo(aIntVal);
assertThat(sampleBean.getProtectedStringField()).isEqualTo(aStringVal);
}
use of org.jdbi.v3.core.SampleBean in project jdbi by jdbi.
the class BeanMapperTest method shouldSetValuesOnPublicSetter.
@Test
public void shouldSetValuesOnPublicSetter() throws Exception {
mockColumns("longField");
Long expected = 1L;
mockLongResult(expected);
SampleBean sampleBean = mapper.map(resultSet, ctx);
assertThat(sampleBean.getLongField()).isEqualTo(expected);
}
use of org.jdbi.v3.core.SampleBean in project jdbi by jdbi.
the class BeanMapperTest method shouldNotThrowOnMismatchedColumns.
@Test
public void shouldNotThrowOnMismatchedColumns() throws Exception {
mockColumns("longField", "extraColumn");
Long expected = 666L;
when(resultSet.getLong(1)).thenReturn(expected);
when(resultSet.getString(2)).thenReturn("foo");
SampleBean sampleBean = mapper.map(resultSet, ctx);
assertThat(sampleBean.getLongField()).isEqualTo(expected);
}
Aggregations