use of org.simpleflatmapper.reflect.getter.ConstantLongGetter in project SimpleFlatMapper by arnaudroger.
the class AsmFactoryTest method testCreateInstantiatorFinalDbObjectInjectIdAndName.
@Test
public void testCreateInstantiatorFinalDbObjectInjectIdAndName() throws Exception {
ExecutableInstantiatorDefinition instantiatorDefinition = (ExecutableInstantiatorDefinition) AsmInstantiatorDefinitionFactory.extractDefinitions(DbFinalObject.class).get(0);
HashMap<Parameter, Getter<? super Object, ?>> injections = new HashMap<Parameter, Getter<? super Object, ?>>();
injections.put(new Parameter(0, "id", long.class), new ConstantLongGetter<Object>(33l));
injections.put(new Parameter(1, "name", String.class), new ConstantGetter<Object, String>("fdo"));
Instantiator<Object, DbFinalObject> instantiator = asmFactory.createInstantiator(Object.class, instantiatorDefinition, injections, true);
DbFinalObject fdo = instantiator.newInstance(new Object());
assertNotNull(fdo);
assertNull(fdo.getEmail());
assertNull(fdo.getCreationTime());
assertNull(fdo.getTypeName());
assertNull(fdo.getTypeOrdinal());
assertEquals(33l, fdo.getId());
assertEquals("fdo", fdo.getName());
assertSame(instantiator.getClass(), asmFactory.createInstantiator(Object.class, instantiatorDefinition, injections, true).getClass());
}
Aggregations