RouteEndpoint implements Endpoint { @Override public CompletionStage<Response<ByteString>> invoke(RequestContext requestContext) { return target.handler() .invoke(requestContext); } RouteEndpoint(Route<? extends AsyncHandler<Response<ByteString>>> target);   RouteEndpoint(Route<? extends AsyncHandler<Response<ByteString>>> target, String methodName); @Override EndpointInfo info(); @Override CompletionStage<Response<ByteString>> invoke(RequestContext requestContext);  }
@Test public void shouldReturnResultOfSyncRoute() throws Exception { when(syncEndpointHandler.invoke(requestContext)) .thenReturn(response); endpoint = new RouteEndpoint(Route.sync("GET", "http: Response<?> actualResponse = endpoint.invoke(requestContext).toCompletableFuture().get(); assertThat(actualResponse.payload(), equalTo(Optional.of(theData))); }
@Test public void shouldReturnResultOfAsyncRoute() throws Exception { when(asyncHandler.invoke(requestContext)) .thenReturn(completedFuture(response)); endpoint = new RouteEndpoint(Route.create("GET", "http: Response<?> actualResponse = endpoint.invoke(requestContext).toCompletableFuture().get(); assertThat(actualResponse.payload(), equalTo(Optional.of(theData))); }