Search in sources :

Example 1 with DbPrimitiveObjectWithSetter

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());
}
Also used : DbPrimitiveObjectWithSetter(org.simpleflatmapper.test.beans.DbPrimitiveObjectWithSetter) LongDelayedCellSetter(org.simpleflatmapper.csv.impl.primitive.LongDelayedCellSetter) Test(org.junit.Test)

Example 2 with DbPrimitiveObjectWithSetter

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());
}
Also used : CharDelayedCellSetter(org.simpleflatmapper.csv.impl.primitive.CharDelayedCellSetter) DbPrimitiveObjectWithSetter(org.simpleflatmapper.test.beans.DbPrimitiveObjectWithSetter) Test(org.junit.Test)

Example 3 with DbPrimitiveObjectWithSetter

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());
}
Also used : DbPrimitiveObjectWithSetter(org.simpleflatmapper.test.beans.DbPrimitiveObjectWithSetter) BooleanDelayedCellSetter(org.simpleflatmapper.csv.impl.primitive.BooleanDelayedCellSetter) Test(org.junit.Test)

Example 4 with DbPrimitiveObjectWithSetter

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());
}
Also used : DbPrimitiveObjectWithSetter(org.simpleflatmapper.test.beans.DbPrimitiveObjectWithSetter) FloatDelayedCellSetter(org.simpleflatmapper.csv.impl.primitive.FloatDelayedCellSetter) Test(org.junit.Test)

Example 5 with DbPrimitiveObjectWithSetter

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");
}
Also used : DbPrimitiveObjectWithSetter(org.simpleflatmapper.test.beans.DbPrimitiveObjectWithSetter) ConstantSourceFieldMapperFactoryImplTest(org.simpleflatmapper.test.map.fieldmapper.ConstantSourceFieldMapperFactoryImplTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)10 DbPrimitiveObjectWithSetter (org.simpleflatmapper.test.beans.DbPrimitiveObjectWithSetter)10 DecimalFormat (java.text.DecimalFormat)1 CsvColumnKey (org.simpleflatmapper.csv.CsvColumnKey)1 BooleanDelayedCellSetter (org.simpleflatmapper.csv.impl.primitive.BooleanDelayedCellSetter)1 ByteDelayedCellSetter (org.simpleflatmapper.csv.impl.primitive.ByteDelayedCellSetter)1 CharDelayedCellSetter (org.simpleflatmapper.csv.impl.primitive.CharDelayedCellSetter)1 DoubleDelayedCellSetter (org.simpleflatmapper.csv.impl.primitive.DoubleDelayedCellSetter)1 FloatDelayedCellSetter (org.simpleflatmapper.csv.impl.primitive.FloatDelayedCellSetter)1 IntDelayedCellSetter (org.simpleflatmapper.csv.impl.primitive.IntDelayedCellSetter)1 LongDelayedCellSetter (org.simpleflatmapper.csv.impl.primitive.LongDelayedCellSetter)1 ShortDelayedCellSetter (org.simpleflatmapper.csv.impl.primitive.ShortDelayedCellSetter)1 DateFormatProperty (org.simpleflatmapper.map.property.DateFormatProperty)1 FormatProperty (org.simpleflatmapper.map.property.FormatProperty)1 ConstantSourceFieldMapperFactoryImplTest (org.simpleflatmapper.test.map.fieldmapper.ConstantSourceFieldMapperFactoryImplTest)1