use of com.tvd12.ezyhttp.server.core.asm.RequestHandlerImplementer in project ezyhttp by youngmonkeys.
the class RequestHandlerImplementerTest method test.
@Test
public void test() {
RequestHandlerImplementer.setDebug(true);
ControllerProxy homeController = new ControllerProxy(new HomeController());
for (RequestHandlerMethod method : homeController.getRequestHandlerMethods()) {
RequestHandlerImplementer implementer = new RequestHandlerImplementer(homeController, method);
implementer.implement();
}
}
use of com.tvd12.ezyhttp.server.core.asm.RequestHandlerImplementer in project ezyhttp by youngmonkeys.
the class RequestHandlerImplementerTest method implementOneFailed.
@Test
public void implementOneFailed() throws Exception {
// given
ControllerProxy controller = new ControllerProxy(new Controller());
RequestHandlerMethod handlerMethod = new RequestHandlerMethod("/", new EzyMethod(Controller.class.getDeclaredMethod("doGet")));
RequestHandlerImplementer sut = new RequestHandlerImplementer(controller, handlerMethod);
// when
Throwable e = Asserts.assertThrows(sut::implement);
// then
Asserts.assertEquals(0, handlerMethod.getParameterTypes().length);
Asserts.assertThat(e).isEqualsType(IllegalStateException.class);
}
use of com.tvd12.ezyhttp.server.core.asm.RequestHandlerImplementer in project ezyhttp by youngmonkeys.
the class RequestHandlerImplementerTest method test.
@Test
public void test() {
RequestHandlerImplementer.setDebug(true);
ControllerProxy homeController = new ControllerProxy(new HomeController());
for (RequestHandlerMethod method : homeController.getRequestHandlerMethods()) {
RequestHandlerImplementer implementer = new RequestHandlerImplementer(homeController, method);
implementer.implement();
}
}
use of com.tvd12.ezyhttp.server.core.asm.RequestHandlerImplementer in project ezyhttp by youngmonkeys.
the class RequestHandlerImplementerTest method test.
@Test
public void test() {
RequestHandlerImplementer.setDebug(true);
ControllerProxy homeController = new ControllerProxy(new HomeController());
for (RequestHandlerMethod method : homeController.getRequestHandlerMethods()) {
RequestHandlerImplementer implementer = new RequestHandlerImplementer(homeController, method);
implementer.implement();
}
}
use of com.tvd12.ezyhttp.server.core.asm.RequestHandlerImplementer in project ezyhttp by youngmonkeys.
the class RequestHandlersImplementer method implement.
public Map<RequestURI, List<RequestHandler>> implement(Object controller) {
Map<RequestURI, List<RequestHandler>> handlers = new HashMap<>();
ControllerProxy proxy = new ControllerProxy(controller);
String feature = proxy.getFeature();
for (RequestHandlerMethod method : proxy.getRequestHandlerMethods()) {
RequestHandlerImplementer implementer = newImplementer(proxy, method);
RequestHandler handler = implementer.implement();
HttpMethod httpMethod = handler.getMethod();
String requestURI = handler.getRequestURI();
String methodFeature = method.getFeature();
RequestURIMeta uriMeta = RequestURIMeta.builder().api(method.isApi() || proxy.isApi()).authenticated(method.isAuthenticated() || proxy.isAuthenticated()).management(method.isManagement() || proxy.isManagement()).payment(method.isPayment() || proxy.isPayment()).feature(methodFeature != null ? methodFeature : feature).build();
RequestURI uri = new RequestURI(httpMethod, requestURI, uriMeta);
handlers.computeIfAbsent(uri, k -> new ArrayList<>()).add(handler);
}
return handlers;
}
Aggregations