Search in sources :

Example 1 with IdentityFieldMapperColumnDefinitionProvider

use of org.simpleflatmapper.map.impl.IdentityFieldMapperColumnDefinitionProvider in project SimpleFlatMapper by arnaudroger.

the class ConstantSourceMapperBuilderTest method testMapInnerObjectWithMapper.

@Test
public void testMapInnerObjectWithMapper() throws Exception {
    ConstantSourceMapperBuilder<Object, MyObjectWithInner, SampleFieldKey> constantSourceMapperBuilder = new ConstantSourceMapperBuilder<Object, MyObjectWithInner, SampleFieldKey>(mapperSource, classMeta, MapperConfig.config(new IdentityFieldMapperColumnDefinitionProvider<SampleFieldKey>()), new MappingContextFactoryBuilder<Object, SampleFieldKey>(null), SampleFieldKey.KEY_FACTORY);
    constantSourceMapperBuilder.addMapping(new SampleFieldKey("prop_date", 0), FieldMapperColumnDefinition.<SampleFieldKey>identity());
    Mapper<Object, MyObjectWithInner> mapper = constantSourceMapperBuilder.mapper();
    MyObjectWithInner o = mapper.map(null);
    assertEquals(DATE, o.prop.date);
    assertNull(o.prop.str);
}
Also used : IdentityFieldMapperColumnDefinitionProvider(org.simpleflatmapper.map.impl.IdentityFieldMapperColumnDefinitionProvider) SampleFieldKey(org.simpleflatmapper.test.map.SampleFieldKey) ConstantSourceMapperBuilder(org.simpleflatmapper.map.mapper.ConstantSourceMapperBuilder) Test(org.junit.Test)

Example 2 with IdentityFieldMapperColumnDefinitionProvider

use of org.simpleflatmapper.map.impl.IdentityFieldMapperColumnDefinitionProvider in project SimpleFlatMapper by arnaudroger.

the class ConstantSourceMapperBuilderTest method testAnonymousParameterWithDifferentType.

@Test
public void testAnonymousParameterWithDifferentType() throws Exception {
    ConstantSourceMapperBuilder<Object, MyObjectWithInner, SampleFieldKey> constantSourceMapperBuilder = new ConstantSourceMapperBuilder<Object, MyObjectWithInner, SampleFieldKey>(mapperSource, classMeta, MapperConfig.config(new IdentityFieldMapperColumnDefinitionProvider<SampleFieldKey>()), new MappingContextFactoryBuilder<Object, SampleFieldKey>(null), SampleFieldKey.KEY_FACTORY);
    constantSourceMapperBuilder.addMapping(new SampleFieldKey("prop", 0, Date.class), FieldMapperColumnDefinition.<SampleFieldKey>identity());
    Mapper<Object, MyObjectWithInner> mapper = constantSourceMapperBuilder.mapper();
    MyObjectWithInner o = mapper.map(null);
    assertEquals(DATE, o.prop.date);
    assertNull(o.prop.str);
}
Also used : IdentityFieldMapperColumnDefinitionProvider(org.simpleflatmapper.map.impl.IdentityFieldMapperColumnDefinitionProvider) SampleFieldKey(org.simpleflatmapper.test.map.SampleFieldKey) ConstantSourceMapperBuilder(org.simpleflatmapper.map.mapper.ConstantSourceMapperBuilder) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 IdentityFieldMapperColumnDefinitionProvider (org.simpleflatmapper.map.impl.IdentityFieldMapperColumnDefinitionProvider)2 ConstantSourceMapperBuilder (org.simpleflatmapper.map.mapper.ConstantSourceMapperBuilder)2 SampleFieldKey (org.simpleflatmapper.test.map.SampleFieldKey)2 Date (java.util.Date)1