@Test public void injectsToPipelineWhenRouteFound() { HttpHandler pipeline = mock(HttpHandler.class); when(pipeline.handle(any(LiveHttpRequest.class), any(HttpInterceptor.Context.class))).thenReturn(Eventual.of(respOk)); HttpRouter router = mock(HttpRouter.class); when(router.route(any(LiveHttpRequest.class), any(HttpInterceptor.Context.class))).thenReturn(Optional.of(pipeline)); LiveHttpResponse response = Mono.from(new RouteHandlerAdapter(router).handle(request, requestContext())).block(); assertThat(response.status(), is(OK)); }
@Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { return router.route(request, context) .map(handler -> handler.handle(request, context)) .orElseGet(() -> Eventual.error(new NoServiceConfiguredException(request.path()))); }
RouteHandlerAdapter implements RoutingObject { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { return router.route(request, context) .map(handler -> handler.handle(request, context)) .orElseGet(() -> Eventual.error(new NoServiceConfiguredException(request.path()))); } }
RouteHandlerAdapter implements RoutingObject { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { return router.route(request, context) .map(handler -> handler.handle(request, context)) .orElseGet(() -> Eventual.error(new NoServiceConfiguredException(request.path()))); } RouteHandlerAdapter(HttpRouter router); }
RouteHandlerAdapter implements RoutingObject { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { return router.route(request, context) .map(handler -> handler.handle(request, context)) .orElseGet(() -> Eventual.error(new NoServiceConfiguredException(request.path()))); } RouteHandlerAdapter(HttpRouter router); @Override Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context); }
RouteHandlerAdapter implements RoutingObject { @Override public Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context) { return router.route(request, context) .map(handler -> handler.handle(request, context)) .orElseGet(() -> Eventual.error(new NoServiceConfiguredException(request.path()))); } RouteHandlerAdapter(HttpRouter router); @Override Eventual<LiveHttpResponse> handle(LiveHttpRequest request, HttpInterceptor.Context context);  }