Search in sources :

Example 1 with IntDelayedCellSetter

use of org.simpleflatmapper.csv.impl.primitive.IntDelayedCellSetter in project SimpleFlatMapper by arnaudroger.

the class PrimitivesDelayedCellSetterTest method testIntGetSetValue.

@Test
public void testIntGetSetValue() throws Exception {
    Setter<DbPrimitiveObjectWithSetter, Integer> intSetter = objectSetterFactory.getSetter(DbPrimitiveObjectWithSetter.class, "pInt");
    IntDelayedCellSetter<DbPrimitiveObjectWithSetter> setter = new IntDelayedCellSetter<DbPrimitiveObjectWithSetter>(ObjectSetterFactory.toIntSetter(intSetter), new IntegerCellValueReaderImpl());
    setter.set("13".toCharArray(), 0, 2, null);
    assertEquals(new Integer(13), setter.consumeValue());
    setter.set("13".toCharArray(), 0, 2, null);
    DbPrimitiveObjectWithSetter o = new DbPrimitiveObjectWithSetter();
    setter.set(o);
    assertEquals(13, o.getpInt());
    setter.set("".toCharArray(), 0, 0, null);
    assertNull(setter.consumeValue());
}
Also used : DbPrimitiveObjectWithSetter(org.simpleflatmapper.test.beans.DbPrimitiveObjectWithSetter) IntDelayedCellSetter(org.simpleflatmapper.csv.impl.primitive.IntDelayedCellSetter) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 IntDelayedCellSetter (org.simpleflatmapper.csv.impl.primitive.IntDelayedCellSetter)1 DbPrimitiveObjectWithSetter (org.simpleflatmapper.test.beans.DbPrimitiveObjectWithSetter)1