use of org.jdbi.v3.core.SampleBean in project jdbi by jdbi.
the class BeanMapperTest method shouldUseRegisteredMapperForUnknownPropertyType.
@Test
public void shouldUseRegisteredMapperForUnknownPropertyType() throws Exception {
handle.registerColumnMapper(new ValueTypeMapper());
mockColumns("longField", "valueTypeField");
Long expected = 123L;
when(resultSet.getLong(1)).thenReturn(expected);
when(resultSet.getString(2)).thenReturn("foo");
when(resultSet.wasNull()).thenReturn(false);
SampleBean sampleBean = mapper.map(resultSet, ctx);
assertThat(sampleBean.getLongField()).isEqualTo(expected);
assertThat(sampleBean.getValueTypeField()).isEqualTo(ValueType.valueOf("foo"));
}
use of org.jdbi.v3.core.SampleBean in project jdbi by jdbi.
the class BeanMapperTest method shouldSetValueOnPublicSetter.
@Test
public void shouldSetValueOnPublicSetter() throws Exception {
mockColumns("longField");
Long aLongVal = 100L;
mockLongResult(aLongVal);
SampleBean sampleBean = mapper.map(resultSet, ctx);
assertThat(sampleBean.getLongField()).isEqualTo(aLongVal);
}
use of org.jdbi.v3.core.SampleBean in project jdbi by jdbi.
the class BeanMapperTest method shouldBeCaseInSensitiveOfColumnAndPropertyNames.
@Test
public void shouldBeCaseInSensitiveOfColumnAndPropertyNames() throws Exception {
mockColumns("LoNgfielD");
Long aLongVal = 100L;
mockLongResult(aLongVal);
SampleBean sampleBean = mapper.map(resultSet, ctx);
assertThat(sampleBean.getLongField()).isEqualTo(aLongVal);
}
use of org.jdbi.v3.core.SampleBean in project jdbi by jdbi.
the class FieldMapperTest method shouldUseRegisteredMapperForUnknownPropertyType.
@Test
public void shouldUseRegisteredMapperForUnknownPropertyType() throws Exception {
handle.registerColumnMapper(new ValueTypeMapper());
mockColumns("longField", "valueTypeField");
when(resultSet.getLong(1)).thenReturn(123L);
when(resultSet.getString(2)).thenReturn("foo");
when(resultSet.wasNull()).thenReturn(false);
SampleBean sampleBean = mapper.map(resultSet, ctx);
Long expected = 123L;
assertThat(sampleBean.getLongField()).isEqualTo(expected);
assertThat(sampleBean.getValueTypeField()).isEqualTo(ValueType.valueOf("foo"));
}
use of org.jdbi.v3.core.SampleBean in project jdbi by jdbi.
the class FieldMapperTest method shouldHandleNullValue.
@Test
public void shouldHandleNullValue() throws Exception {
mockColumns("LoNgfielD");
when(resultSet.getLong(1)).thenReturn(0L);
when(resultSet.wasNull()).thenReturn(true);
SampleBean sampleBean = mapper.map(resultSet, ctx);
assertThat(sampleBean.getLongField()).isNull();
}
Aggregations