use of org.simpleflatmapper.map.FieldKey in project SimpleFlatMapper by arnaudroger.
the class AbstractMapperFactoryTest method testErrorHandlers.
@Test
public void testErrorHandlers() {
MapperFactory mapperFactory = new MapperFactory();
FieldMapperErrorHandler<SampleFieldKey> fieldMapperErrorHandler = new FieldMapperErrorHandler<SampleFieldKey>() {
@Override
public void errorMappingField(SampleFieldKey key, Object source, Object target, Exception error) throws MappingException {
}
};
MapperBuilderErrorHandler mapperBuilderErrorHandler = new MapperBuilderErrorHandler() {
@Override
public void accessorNotFound(String msg) {
}
@Override
public void propertyNotFound(Type target, String property) {
}
@Override
public void customFieldError(FieldKey<?> key, String message) {
}
};
ConsumerErrorHandler consumerErrorHandler = new ConsumerErrorHandler() {
@Override
public void handlerError(Throwable error, Object target) {
}
};
mapperFactory.fieldMapperErrorHandler(fieldMapperErrorHandler);
mapperFactory.mapperBuilderErrorHandler(mapperBuilderErrorHandler);
mapperFactory.consumerErrorHandler(consumerErrorHandler);
MapperConfig<SampleFieldKey, FieldMapperColumnDefinition<SampleFieldKey>> mapperConfig = mapperFactory.mapperConfig();
assertEquals(fieldMapperErrorHandler, mapperConfig.fieldMapperErrorHandler());
assertEquals(mapperBuilderErrorHandler, mapperConfig.mapperBuilderErrorHandler());
assertEquals(consumerErrorHandler, mapperConfig.consumerErrorHandler());
Assert.assertEquals(consumerErrorHandler, mapperFactory.consumerErrorHandler());
mapperFactory = new MapperFactory();
assertTrue(mapperFactory.ignorePropertyNotFound().mapperConfig().mapperBuilderErrorHandler() instanceof IgnoreMapperBuilderErrorHandler);
}
use of org.simpleflatmapper.map.FieldKey in project SimpleFlatMapper by arnaudroger.
the class AbstractMapperFactoryTest method testPropertyNameMatcherFactory.
@Test
public void testPropertyNameMatcherFactory() {
PropertyNameMatcherFactory factory = new PropertyNameMatcherFactory() {
@Override
public PropertyNameMatcher newInstance(FieldKey<?> key) {
return null;
}
};
assertSame(factory, new MapperFactory().propertyNameMatcherFactory(factory).mapperConfig().propertyNameMatcherFactory());
}
Aggregations