use of org.simpleflatmapper.test.map.SampleFieldKey in project SimpleFlatMapper by arnaudroger.
the class MappingContextFactoryBuilderTest method testKeys.
@Test
public void testKeys() throws Exception {
builder.addKey(new SampleFieldKey("k1", 0));
assertFalse(builder.hasNoKeys());
MappingContextFactory<Object[]> mappingContextFactory = builder.newFactory();
assertTrue(mappingContextFactory instanceof BreakDetectorMappingContextFactory);
assertNull(mappingContextFactory.newContext().context(0));
assertTrue(builder.nullChecker().test(new Object[] { null }));
assertFalse(builder.nullChecker().test(new Object[] { 123 }));
}
use of org.simpleflatmapper.test.map.SampleFieldKey in project SimpleFlatMapper by arnaudroger.
the class MappingContextFactoryBuilderTest method testKeysWithSubBuilder.
@Test
public void testKeysWithSubBuilder() {
builder.addKey(new SampleFieldKey("k1", 0));
MappingContextFactoryBuilder<Object[], SampleFieldKey> subBuilder = builder.newBuilder(Arrays.asList(new SampleFieldKey("k2", 3)), null);
subBuilder.newBuilder(Arrays.asList(new SampleFieldKey("k3", 6)), null);
MappingContextFactory<Object[]> mappingContextFactory = builder.newFactory();
MappingContext<Object[]> mappingContext = mappingContextFactory.newContext();
}
use of org.simpleflatmapper.test.map.SampleFieldKey in project SimpleFlatMapper by arnaudroger.
the class Issue365Test method mapperConfig.
private MapperConfig<SampleFieldKey, FieldMapperColumnDefinition<SampleFieldKey>> mapperConfig() {
FieldMapperColumnDefinitionProviderImpl<SampleFieldKey> provider = new FieldMapperColumnDefinitionProviderImpl<SampleFieldKey>();
provider.addColumnDefinition("benchmark", FieldMapperColumnDefinition.<SampleFieldKey>identity().add(new SetterProperty(SETTER)).add(new GetterProperty(GETTER)));
return MapperConfig.<SampleFieldKey>fieldMapperConfig().columnDefinitions(provider);
}
use of org.simpleflatmapper.test.map.SampleFieldKey in project SimpleFlatMapper by arnaudroger.
the class ConstantSourceFieldMapperFactoryImplTest method createPropertyMapping.
public static <T, P> PropertyMapping<T, P, SampleFieldKey, FieldMapperColumnDefinition<SampleFieldKey>> createPropertyMapping(Class<T> target, String property) {
ClassMeta<T> classMeta = REFLECTION_SERVICE.getClassMeta(target);
PropertyMeta<T, P> propertyMeta = classMeta.newPropertyFinder(ConstantPredicate.<PropertyMeta<?, ?>>truePredicate()).findProperty(DefaultPropertyNameMatcher.of(property), new Object[0]);
PropertyMapping<T, P, SampleFieldKey, FieldMapperColumnDefinition<SampleFieldKey>> pm = new PropertyMapping<T, P, SampleFieldKey, FieldMapperColumnDefinition<SampleFieldKey>>(propertyMeta, new SampleFieldKey(property, 0), FieldMapperColumnDefinition.<SampleFieldKey>identity());
return pm;
}
use of org.simpleflatmapper.test.map.SampleFieldKey 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);
}
Aggregations