Search in sources :

Example 1 with HttpRouter

use of com.hotels.styx.server.HttpRouter in project styx by ExpediaGroup.

the class RouteHandlerAdapterTest method injectsToPipelineWhenRouteFound.

@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));
}
Also used : Support.requestContext(com.hotels.styx.support.Support.requestContext) HttpHandler(com.hotels.styx.api.HttpHandler) LiveHttpRequest(com.hotels.styx.api.LiveHttpRequest) LiveHttpResponse(com.hotels.styx.api.LiveHttpResponse) HttpRouter(com.hotels.styx.server.HttpRouter) Test(org.junit.jupiter.api.Test)

Aggregations

HttpHandler (com.hotels.styx.api.HttpHandler)1 LiveHttpRequest (com.hotels.styx.api.LiveHttpRequest)1 LiveHttpResponse (com.hotels.styx.api.LiveHttpResponse)1 HttpRouter (com.hotels.styx.server.HttpRouter)1 Support.requestContext (com.hotels.styx.support.Support.requestContext)1 Test (org.junit.jupiter.api.Test)1