assertTrue(deserializedAggregate.isLive());
}
@Test
public void testAggregateRetrievesParameterResolverFactoryFromUnitOfWork() {
UnitOfWork uow = DefaultUnitOfWork.startAndGet();
uow.attachResource(ParameterResolverFactory.class.getName(), MultiParameterResolverFactory.ordered(
ClasspathParameterResolverFactory.forClass(CustomParameterAggregateRoot.class),
new ParameterResolverFactory() {
@Override
public ParameterResolver createInstance(Annotation[] memberAnnotations, Class<?> parameterType,
Annotation[] parameterAnnotations) {
if (String.class.equals(parameterType)) {
return new FixedValueParameterResolver<String>("It works");
}
return null;
}
}));
CustomParameterAggregateRoot aggregateRoot = new CustomParameterAggregateRoot();
aggregateRoot.doSomething();
assertEquals("It works", aggregateRoot.secondParameter);
uow.rollback();
}