use of org.simpleflatmapper.test.beans.DbPrimitiveObjectWithSetter in project SimpleFlatMapper by arnaudroger.
the class PrimitivesDelayedCellSetterTest method testLongGetSetValue.
@Test
public void testLongGetSetValue() throws Exception {
Setter<DbPrimitiveObjectWithSetter, Long> longSetter = objectSetterFactory.getSetter(DbPrimitiveObjectWithSetter.class, "pLong");
LongDelayedCellSetter<DbPrimitiveObjectWithSetter> setter = new LongDelayedCellSetter<DbPrimitiveObjectWithSetter>(ObjectSetterFactory.toLongSetter(longSetter), new LongCellValueReaderImpl());
setter.set("13".toCharArray(), 0, 2, null);
assertEquals(new Long(13), setter.consumeValue());
setter.set("13".toCharArray(), 0, 2, null);
DbPrimitiveObjectWithSetter o = new DbPrimitiveObjectWithSetter();
setter.set(o);
assertEquals(13, o.getpLong());
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 testCharGetSetValue.
@Test
public void testCharGetSetValue() throws Exception {
Setter<DbPrimitiveObjectWithSetter, Character> charSetter = objectSetterFactory.getSetter(DbPrimitiveObjectWithSetter.class, "pChar");
CharDelayedCellSetter<DbPrimitiveObjectWithSetter> setter = new CharDelayedCellSetter<DbPrimitiveObjectWithSetter>(ObjectSetterFactory.toCharacterSetter(charSetter), new CharCellValueReaderImpl());
setter.set("13".toCharArray(), 0, 2, null);
assertEquals(new Character((char) 13), setter.consumeValue());
setter.set("13".toCharArray(), 0, 2, null);
DbPrimitiveObjectWithSetter o = new DbPrimitiveObjectWithSetter();
setter.set(o);
assertEquals((char) 13, o.getpCharacter());
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 testBooleanGetSetValue.
@Test
public void testBooleanGetSetValue() throws Exception {
Setter<DbPrimitiveObjectWithSetter, Boolean> setter = objectSetterFactory.getSetter(DbPrimitiveObjectWithSetter.class, "pBoolean");
BooleanDelayedCellSetter<DbPrimitiveObjectWithSetter> bSetter = new BooleanDelayedCellSetter<DbPrimitiveObjectWithSetter>(ObjectSetterFactory.toBooleanSetter(setter), new BooleanCellValueReaderImpl());
bSetter.set("true".toCharArray(), 0, 4, null);
assertTrue(bSetter.consumeValue());
bSetter.set("true".toCharArray(), 0, 4, null);
DbPrimitiveObjectWithSetter o = new DbPrimitiveObjectWithSetter();
bSetter.set(o);
assertTrue(o.ispBoolean());
bSetter.set("".toCharArray(), 0, 0, null);
assertNull(bSetter.consumeValue());
}
use of org.simpleflatmapper.test.beans.DbPrimitiveObjectWithSetter in project SimpleFlatMapper by arnaudroger.
the class PrimitivesDelayedCellSetterTest method testFloatGetSetValue.
@Test
public void testFloatGetSetValue() throws Exception {
Setter<DbPrimitiveObjectWithSetter, Float> floatSetter = objectSetterFactory.getSetter(DbPrimitiveObjectWithSetter.class, "pFloat");
FloatDelayedCellSetter<DbPrimitiveObjectWithSetter> setter = new FloatDelayedCellSetter<DbPrimitiveObjectWithSetter>(ObjectSetterFactory.toFloatSetter(floatSetter), new FloatCellValueReaderImpl());
setter.set("13".toCharArray(), 0, 2, null);
assertEquals(new Float(13), setter.consumeValue());
setter.set("13".toCharArray(), 0, 2, null);
DbPrimitiveObjectWithSetter o = new DbPrimitiveObjectWithSetter();
setter.set(o);
assertEquals(13, o.getpFloat(), 0);
setter.set("".toCharArray(), 0, 0, null);
assertNull(setter.consumeValue());
}
use of org.simpleflatmapper.test.beans.DbPrimitiveObjectWithSetter in project SimpleFlatMapper by arnaudroger.
the class ConstantTargetFieldMapperFactoryImplTest method testPrimitiveMapping.
@Test
public void testPrimitiveMapping() throws Exception {
DbPrimitiveObjectWithSetter objectWithSetter = new DbPrimitiveObjectWithSetter();
objectWithSetter.setpBoolean(true);
objectWithSetter.setpByte((byte) 52);
objectWithSetter.setpCharacter('a');
objectWithSetter.setpShort((short) 139);
objectWithSetter.setpInt(12345);
objectWithSetter.setpLong(1234567);
objectWithSetter.setpFloat((float) 1.23);
objectWithSetter.setpDouble(1.234567);
testMapping(objectWithSetter, "pBoolean", "Ztrue");
testMapping(objectWithSetter, "pByte", "B52");
testMapping(objectWithSetter, "pCharacter", "Ca");
testMapping(objectWithSetter, "pShort", "S139");
testMapping(objectWithSetter, "pInt", "I12345");
testMapping(objectWithSetter, "pLong", "L1234567");
testMapping(objectWithSetter, "pFloat", "F1.23");
testMapping(objectWithSetter, "pDouble", "D1.234567");
}
Aggregations