Search in sources :

Example 6 with GreetingsCallbackBuilders

use of com.linkedin.restli.examples.greetings.client.GreetingsCallbackBuilders in project rest.li by linkedin.

the class TestMultiplexerIntegration method singleCall.

@Test
public void singleCall() throws Exception {
    GetRequest<Greeting> request = new GreetingsCallbackBuilders().get().id(1L).build();
    FutureCallback<Response<Greeting>> muxCallback = new FutureCallback<Response<Greeting>>();
    FutureCallback<Response<Greeting>> directCallback = new FutureCallback<Response<Greeting>>();
    FutureCallback<MultiplexedResponse> aggregatedCallback = new FutureCallback<MultiplexedResponse>();
    MultiplexedRequest multiplexedRequest = MultiplexedRequestBuilder.createParallelRequest().addRequest(request, muxCallback).build();
    getClient().sendRequest(multiplexedRequest, aggregatedCallback);
    getClient().sendRequest(request, directCallback);
    assertEqualResponses(muxCallback, directCallback);
    MultiplexedResponse multiplexedResponse = aggregatedCallback.get();
    Assert.assertEquals(multiplexedResponse.getStatus(), HttpStatus.S_200_OK.getCode());
    Assert.assertFalse(multiplexedResponse.getHeaders().isEmpty());
}
Also used : Response(com.linkedin.restli.client.Response) Greeting(com.linkedin.restli.examples.greetings.api.Greeting) FutureCallback(com.linkedin.common.callback.FutureCallback) GreetingsCallbackBuilders(com.linkedin.restli.examples.greetings.client.GreetingsCallbackBuilders) RestLiIntegrationTest(com.linkedin.restli.examples.RestLiIntegrationTest) Test(org.testng.annotations.Test)

Aggregations

FutureCallback (com.linkedin.common.callback.FutureCallback)6 Response (com.linkedin.restli.client.Response)6 RestLiIntegrationTest (com.linkedin.restli.examples.RestLiIntegrationTest)6 Greeting (com.linkedin.restli.examples.greetings.api.Greeting)6 GreetingsCallbackBuilders (com.linkedin.restli.examples.greetings.client.GreetingsCallbackBuilders)6 Test (org.testng.annotations.Test)6