Search in sources :

Example 1 with DelayedCellSetterImpl

use of org.simpleflatmapper.csv.impl.cellreader.DelayedCellSetterImpl in project SimpleFlatMapper by arnaudroger.

the class CsvMapperCellHandlerImpAsmInstantiatorTest method testInstantiateStringWithCharArray.

@SuppressWarnings("unchecked")
@Test
public void testInstantiateStringWithCharArray() throws Exception {
    HashMap<Parameter, Getter<? super CsvMapperCellHandlerImpl<String>, ?>> injections = new HashMap<Parameter, Getter<? super CsvMapperCellHandlerImpl<String>, ?>>();
    Parameter parameter = new Parameter(0, "arg0", char[].class);
    DelayedGetter delayedGetter = new DelayedGetter(0);
    injections.put(parameter, delayedGetter);
    Class<CsvMapperCellHandlerImpl<String>> source = (Class) CsvMapperCellHandlerImpl.class;
    Instantiator<CsvMapperCellHandlerImpl<String>, String> instantiator = factory.createInstantiator(source, new ExecutableInstantiatorDefinition(String.class.getConstructor(char[].class), parameter), injections, true);
    DelayedCellSetterImpl delayedCellSetter = new DelayedCellSetterImpl(null, new CellValueReader() {

        @Override
        public char[] read(char[] chars, int offset, int length, ParsingContext parsingContext) {
            return new char[] { 'h' };
        }
    });
    delayedCellSetter.set(null, 0, 0, null);
    CsvMapperCellHandlerImpl targetSettersImpl = new CsvMapperCellHandlerImpl(instantiator, new DelayedCellSetter[] { delayedCellSetter }, new CellSetter[] {}, null, null, null);
    Assert.assertNotNull(instantiator.newInstance(targetSettersImpl));
}
Also used : ExecutableInstantiatorDefinition(org.simpleflatmapper.reflect.instantiator.ExecutableInstantiatorDefinition) ParsingContext(org.simpleflatmapper.csv.ParsingContext) HashMap(java.util.HashMap) DelayedCellSetterImpl(org.simpleflatmapper.csv.impl.cellreader.DelayedCellSetterImpl) Getter(org.simpleflatmapper.reflect.Getter) CellValueReader(org.simpleflatmapper.csv.CellValueReader) Parameter(org.simpleflatmapper.reflect.Parameter) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)1 Test (org.junit.Test)1 CellValueReader (org.simpleflatmapper.csv.CellValueReader)1 ParsingContext (org.simpleflatmapper.csv.ParsingContext)1 DelayedCellSetterImpl (org.simpleflatmapper.csv.impl.cellreader.DelayedCellSetterImpl)1 Getter (org.simpleflatmapper.reflect.Getter)1 Parameter (org.simpleflatmapper.reflect.Parameter)1 ExecutableInstantiatorDefinition (org.simpleflatmapper.reflect.instantiator.ExecutableInstantiatorDefinition)1