use of org.simpleflatmapper.reflect.getter.OrdinalEnumGetter in project SimpleFlatMapper by arnaudroger.
the class AsmFactoryTest method testCreateInstantiatorFinalDbObjectNameAndType.
@Test
public void testCreateInstantiatorFinalDbObjectNameAndType() throws Exception {
HashMap<Parameter, Getter<? super Object, ?>> injections = new HashMap<Parameter, Getter<? super Object, ?>>();
ConstantIntGetter<Object> getter = new ConstantIntGetter<Object>(1);
injections.put(new Parameter(4, "typeOrdinal", Type.class), new OrdinalEnumGetter<Object, Type>(getter, Type.class));
injections.put(new Parameter(1, "name", String.class), new ConstantGetter<Object, String>("fdo"));
List<InstantiatorDefinition> instantiatorDefinitions = AsmInstantiatorDefinitionFactory.extractDefinitions(DbFinalObject.class);
Instantiator<Object, DbFinalObject> instantiator = asmFactory.createInstantiator(Object.class, (ExecutableInstantiatorDefinition) instantiatorDefinitions.get(0), injections, true);
DbFinalObject fdo = instantiator.newInstance(new Object());
assertNotNull(fdo);
assertNull(fdo.getEmail());
assertNull(fdo.getCreationTime());
assertNull(fdo.getTypeName());
assertEquals(0, fdo.getId());
assertEquals("fdo", fdo.getName());
assertEquals(Type.type2, fdo.getTypeOrdinal());
}
Aggregations