Search in sources :

Example 1 with SampleBean

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

the class BeanMapperTest method shouldBeCaseInSensitiveOfColumnWithUnderscoresAndPropertyNames.

@Test
public void shouldBeCaseInSensitiveOfColumnWithUnderscoresAndPropertyNames() throws Exception {
    mockColumns("LoNg_FiElD");
    Long aLongVal = 100L;
    mockLongResult(aLongVal);
    SampleBean sampleBean = mapper.map(resultSet, ctx);
    assertThat(sampleBean.getLongField()).isEqualTo(aLongVal);
}
Also used : SampleBean(org.jdbi.v3.core.SampleBean) Test(org.junit.Test)

Example 2 with SampleBean

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

the class BeanMapperTest method shouldHandleEmptyResult.

@Test
public void shouldHandleEmptyResult() throws Exception {
    mockColumns();
    SampleBean sampleBean = mapper.map(resultSet, ctx);
    assertThat(sampleBean).isNotNull();
}
Also used : SampleBean(org.jdbi.v3.core.SampleBean) Test(org.junit.Test)

Example 3 with SampleBean

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

the class BeanMapperTest method shouldHandleColumNameWithUnderscores.

@Test
public void shouldHandleColumNameWithUnderscores() throws Exception {
    mockColumns("LONG_FIELD");
    Long aLongVal = 100L;
    mockLongResult(aLongVal);
    SampleBean sampleBean = mapper.map(resultSet, ctx);
    assertThat(sampleBean.getLongField()).isEqualTo(aLongVal);
}
Also used : SampleBean(org.jdbi.v3.core.SampleBean) Test(org.junit.Test)

Example 4 with SampleBean

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

the class BeanMapperTest method shouldHandleNullValue.

@Test
public void shouldHandleNullValue() throws Exception {
    mockColumns("LoNgfielD");
    mockAllNullsResult();
    SampleBean sampleBean = mapper.map(resultSet, ctx);
    assertThat(sampleBean.getLongField()).isNull();
}
Also used : SampleBean(org.jdbi.v3.core.SampleBean) Test(org.junit.Test)

Example 5 with SampleBean

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

the class FieldMapperTest method shouldSetValueOnPrivateField.

@Test
public void shouldSetValueOnPrivateField() throws Exception {
    mockColumns("longField");
    Long aLongVal = 100L;
    when(resultSet.getLong(1)).thenReturn(aLongVal);
    when(resultSet.wasNull()).thenReturn(false);
    SampleBean sampleBean = mapper.map(resultSet, ctx);
    assertThat(sampleBean.getLongField()).isEqualTo(aLongVal);
}
Also used : SampleBean(org.jdbi.v3.core.SampleBean) Test(org.junit.Test)

Aggregations

SampleBean (org.jdbi.v3.core.SampleBean)16 Test (org.junit.Test)16 ValueTypeMapper (org.jdbi.v3.core.mapper.ValueTypeMapper)2 BigDecimal (java.math.BigDecimal)1