use of cn.taketoday.web.handler.MockResolvableMethodParameter in project today-framework by TAKETODAY.
the class ParameterResolvingRegistryTests method lookupStrategy.
@Test
void lookupStrategy() throws NoSuchMethodException {
Method q = getClass().getDeclaredMethod("p", String.class);
MethodParameter parameter = MethodParameter.forExecutable(q, 0);
ParameterResolvingStrategy data = registry.findStrategy(new MockResolvableMethodParameter(parameter, "data"));
assertThat(data).isNull();
assertThatThrownBy(() -> registry.obtainStrategy(new MockResolvableMethodParameter(parameter, "data"))).isInstanceOf(ParameterResolverNotFoundException.class).hasMessageStartingWith("There isn't have a parameter resolver to resolve parameter");
AnnotationConfigServletWebApplicationContext context = new AnnotationConfigServletWebApplicationContext(Object.class);
context.setServletContext(new MockServletContext());
registry.setApplicationContext(context);
registry.registerDefaultStrategies();
registry.trimToSize();
registry.setRedirectModelManager(null);
assertThat(registry.getRedirectModelManager()).isNull();
data = registry.findStrategy(new MockResolvableMethodParameter(parameter, "data"));
assertThat(data).isNotNull().isEqualTo(registry.obtainStrategy(new MockResolvableMethodParameter(parameter, "data"))).isInstanceOf(ConverterAwareParameterResolver.class);
}
use of cn.taketoday.web.handler.MockResolvableMethodParameter in project today-infrastructure by TAKETODAY.
the class ParameterResolvingRegistryTests method lookupStrategy.
@Test
void lookupStrategy() throws NoSuchMethodException {
Method q = getClass().getDeclaredMethod("p", String.class);
MethodParameter parameter = MethodParameter.forExecutable(q, 0);
ParameterResolvingStrategy data = registry.findStrategy(new MockResolvableMethodParameter(parameter, "data"));
assertThat(data).isNull();
assertThatThrownBy(() -> registry.obtainStrategy(new MockResolvableMethodParameter(parameter, "data"))).isInstanceOf(ParameterResolverNotFoundException.class).hasMessageStartingWith("There isn't have a parameter resolver to resolve parameter");
AnnotationConfigServletWebApplicationContext context = new AnnotationConfigServletWebApplicationContext(Object.class);
context.setServletContext(new MockServletContext());
registry.setApplicationContext(context);
registry.registerDefaultStrategies();
registry.trimToSize();
registry.setRedirectModelManager(null);
assertThat(registry.getRedirectModelManager()).isNull();
data = registry.findStrategy(new MockResolvableMethodParameter(parameter, "data"));
assertThat(data).isNotNull().isEqualTo(registry.obtainStrategy(new MockResolvableMethodParameter(parameter, "data"))).isInstanceOf(ConverterAwareParameterResolver.class);
}
Aggregations