Search in sources :

Example 1 with MapperBuildingException

use of org.simpleflatmapper.map.MapperBuildingException in project SimpleFlatMapper by arnaudroger.

the class ConstantTargetFieldMapperFactoryImplTest method testGetterNotFound.

@Test
public void testGetterNotFound() {
    ConstantTargetFieldMapperFactory<Appendable, SampleFieldKey> factory = ConstantTargetFieldMapperFactoryImpl.<Appendable, SampleFieldKey>newInstance(setterFactory, Appendable.class);
    try {
        PropertyMeta<Object, Object> pm = mock(PropertyMeta.class);
        PropertyMapping<Object, Object, SampleFieldKey, FieldMapperColumnDefinition<SampleFieldKey>> propertyMapping = new PropertyMapping<Object, Object, SampleFieldKey, FieldMapperColumnDefinition<SampleFieldKey>>(pm, new SampleFieldKey("hh", 0), FieldMapperColumnDefinition.<SampleFieldKey>identity());
        factory.newFieldMapper(propertyMapping, null, RethrowMapperBuilderErrorHandler.INSTANCE);
        fail();
    } catch (MapperBuildingException e) {
    }
}
Also used : FieldMapperColumnDefinition(org.simpleflatmapper.map.property.FieldMapperColumnDefinition) PropertyMapping(org.simpleflatmapper.map.mapper.PropertyMapping) MapperBuildingException(org.simpleflatmapper.map.MapperBuildingException) SampleFieldKey(org.simpleflatmapper.test.map.SampleFieldKey) DbObject(org.simpleflatmapper.test.beans.DbObject) ConstantSourceFieldMapperFactoryImplTest(org.simpleflatmapper.test.map.fieldmapper.ConstantSourceFieldMapperFactoryImplTest) Test(org.junit.Test)

Example 2 with MapperBuildingException

use of org.simpleflatmapper.map.MapperBuildingException in project SimpleFlatMapper by arnaudroger.

the class RethrowMapperBuilderErrorHandlerTest method testSetterNotFound.

@Test
public void testSetterNotFound() {
    RethrowMapperBuilderErrorHandler handler = RethrowMapperBuilderErrorHandler.INSTANCE;
    try {
        handler.propertyNotFound(this.getClass(), "prop");
        fail("Expected exception");
    } catch (MapperBuildingException e) {
    }
}
Also used : RethrowMapperBuilderErrorHandler(org.simpleflatmapper.map.error.RethrowMapperBuilderErrorHandler) MapperBuildingException(org.simpleflatmapper.map.MapperBuildingException) Test(org.junit.Test)

Example 3 with MapperBuildingException

use of org.simpleflatmapper.map.MapperBuildingException in project SimpleFlatMapper by arnaudroger.

the class RethrowMapperBuilderErrorHandlerTest method testGetterNotFound.

@Test
public void testGetterNotFound() {
    RethrowMapperBuilderErrorHandler handler = RethrowMapperBuilderErrorHandler.INSTANCE;
    try {
        handler.accessorNotFound("prop");
        fail("Expected exception");
    } catch (MapperBuildingException e) {
    }
}
Also used : RethrowMapperBuilderErrorHandler(org.simpleflatmapper.map.error.RethrowMapperBuilderErrorHandler) MapperBuildingException(org.simpleflatmapper.map.MapperBuildingException) Test(org.junit.Test)

Example 4 with MapperBuildingException

use of org.simpleflatmapper.map.MapperBuildingException in project SimpleFlatMapper by arnaudroger.

the class ConstantSourceMapperBuilder method getConstructorFieldMappersAndInstantiator.

@SuppressWarnings("unchecked")
private InstantiatorAndFieldMappers getConstructorFieldMappersAndInstantiator() throws MapperBuildingException {
    InstantiatorFactory instantiatorFactory = reflectionService.getInstantiatorFactory();
    try {
        ConstructorInjections constructorInjections = constructorInjections();
        Map<Parameter, BiFunction<? super S, ? super MappingContext<? super S>, ?>> injections = constructorInjections.parameterGetterMap;
        MapperBiInstantiatorFactory mapperBiInstantiatorFactory = new MapperBiInstantiatorFactory(instantiatorFactory);
        GetterFactory<? super S, K> getterFactory = fieldMapperAsGetterFactory();
        BiInstantiator<S, MappingContext<? super S>, T> instantiator = mapperBiInstantiatorFactory.<S, T, K, FieldMapperColumnDefinition<K>>getBiInstantiator(mapperSource.source(), target, propertyMappingsBuilder, injections, getterFactory, reflectionService.builderIgnoresNullValues());
        return new InstantiatorAndFieldMappers(constructorInjections.fieldMappers, instantiator);
    } catch (Exception e) {
        return ErrorHelper.rethrow(e);
    }
}
Also used : FieldMapperColumnDefinition(org.simpleflatmapper.map.property.FieldMapperColumnDefinition) MapperBuildingException(org.simpleflatmapper.map.MapperBuildingException) InstantiatorFactory(org.simpleflatmapper.reflect.InstantiatorFactory) MappingContext(org.simpleflatmapper.map.MappingContext) BiFunction(org.simpleflatmapper.util.BiFunction) Parameter(org.simpleflatmapper.reflect.Parameter)

Aggregations

MapperBuildingException (org.simpleflatmapper.map.MapperBuildingException)4 Test (org.junit.Test)3 RethrowMapperBuilderErrorHandler (org.simpleflatmapper.map.error.RethrowMapperBuilderErrorHandler)2 FieldMapperColumnDefinition (org.simpleflatmapper.map.property.FieldMapperColumnDefinition)2 MappingContext (org.simpleflatmapper.map.MappingContext)1 PropertyMapping (org.simpleflatmapper.map.mapper.PropertyMapping)1 InstantiatorFactory (org.simpleflatmapper.reflect.InstantiatorFactory)1 Parameter (org.simpleflatmapper.reflect.Parameter)1 DbObject (org.simpleflatmapper.test.beans.DbObject)1 SampleFieldKey (org.simpleflatmapper.test.map.SampleFieldKey)1 ConstantSourceFieldMapperFactoryImplTest (org.simpleflatmapper.test.map.fieldmapper.ConstantSourceFieldMapperFactoryImplTest)1 BiFunction (org.simpleflatmapper.util.BiFunction)1