use of org.simpleflatmapper.test.beans.DbPrimitiveObjectWithSetter 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());
}
use of org.simpleflatmapper.test.beans.DbPrimitiveObjectWithSetter in project SimpleFlatMapper by arnaudroger.
the class PrimitivesDelayedCellSetterTest method testShortGetSetValue.
@Test
public void testShortGetSetValue() throws Exception {
Setter<DbPrimitiveObjectWithSetter, Short> shortSetter = objectSetterFactory.getSetter(DbPrimitiveObjectWithSetter.class, "pShort");
ShortDelayedCellSetter<DbPrimitiveObjectWithSetter> setter = new ShortDelayedCellSetter<DbPrimitiveObjectWithSetter>(ObjectSetterFactory.toShortSetter(shortSetter), new ShortCellValueReaderImpl());
setter.set("13".toCharArray(), 0, 2, null);
assertEquals(new Short((short) 13), setter.consumeValue());
setter.set("13".toCharArray(), 0, 2, null);
DbPrimitiveObjectWithSetter o = new DbPrimitiveObjectWithSetter();
setter.set(o);
assertEquals((short) 13, o.getpShort());
setter.set("".toCharArray(), 0, 0, null);
assertNull(setter.consumeValue());
}
use of org.simpleflatmapper.test.beans.DbPrimitiveObjectWithSetter in project SimpleFlatMapper by arnaudroger.
the class PrimitivesDelayedCellSetterTest method testDoubleGetSetValue.
@Test
public void testDoubleGetSetValue() throws Exception {
Setter<DbPrimitiveObjectWithSetter, Double> doubleSetter = objectSetterFactory.getSetter(DbPrimitiveObjectWithSetter.class, "pDouble");
DoubleDelayedCellSetter<DbPrimitiveObjectWithSetter> setter = new DoubleDelayedCellSetter<DbPrimitiveObjectWithSetter>(ObjectSetterFactory.toDoubleSetter(doubleSetter), new DoubleCellValueReaderImpl());
setter.set("13".toCharArray(), 0, 2, null);
assertEquals(new Double(13), setter.consumeValue());
setter.set("13".toCharArray(), 0, 2, null);
DbPrimitiveObjectWithSetter o = new DbPrimitiveObjectWithSetter();
setter.set(o);
assertEquals(13, o.getpDouble(), 0);
setter.set("".toCharArray(), 0, 0, null);
assertNull(setter.consumeValue());
}
use of org.simpleflatmapper.test.beans.DbPrimitiveObjectWithSetter in project SimpleFlatMapper by arnaudroger.
the class PrimitivesDelayedCellSetterTest method testByteGetSetValue.
@Test
public void testByteGetSetValue() throws Exception {
Setter<DbPrimitiveObjectWithSetter, Byte> byteSetter = objectSetterFactory.getSetter(DbPrimitiveObjectWithSetter.class, "pByte");
ByteDelayedCellSetter<DbPrimitiveObjectWithSetter> setter = new ByteDelayedCellSetter<DbPrimitiveObjectWithSetter>(ObjectSetterFactory.toByteSetter(byteSetter), new ByteCellValueReaderImpl());
setter.set("13".toCharArray(), 0, 2, null);
assertEquals(new Byte((byte) 13), setter.consumeValue());
setter.set("13".toCharArray(), 0, 2, null);
DbPrimitiveObjectWithSetter o = new DbPrimitiveObjectWithSetter();
setter.set(o);
assertEquals((byte) 13, o.getpByte());
setter.set("".toCharArray(), 0, 0, null);
assertNull(setter.consumeValue());
}
use of org.simpleflatmapper.test.beans.DbPrimitiveObjectWithSetter in project SimpleFlatMapper by arnaudroger.
the class FieldMapperToAppendableFactoryTest method testDoubleWithFormatterAppender.
@Test
public void testDoubleWithFormatterAppender() throws Exception {
MappingContextFactoryBuilder<DbPrimitiveObjectWithSetter, CsvColumnKey> builder = getMappingContextBuilder();
FieldMapperColumnDefinition<CsvColumnKey> format = FieldMapperColumnDefinition.<CsvColumnKey>identity().add(new FormatProperty(new DecimalFormat("0.0")));
FieldMapper<DbPrimitiveObjectWithSetter, Appendable> fieldMapper = defaultFieldAppenderFactory.newFieldMapper(newPropertyMapping("pDouble", dbPrimitiveObjectClassMeta, format), builder, null);
testFieldMapper("3.1", fieldMapper, dbPrimitiveObject, builder.newFactory());
}
Aggregations