use of com.linkedin.restli.common.multiplexer.MultiplexedRequestContent in project rest.li by linkedin.
the class TestMultiplexedRequestBuilder method testParallel.
@Test
public void testParallel() throws RestLiEncodingException {
MultiplexedRequest multiplexedRequest = MultiplexedRequestBuilder.createParallelRequest().addRequest(request1, callback1).addRequest(request2, callback2).build();
//verify requests
IndividualRequest ir1 = fakeIndividualRequest(getUri(ID1));
IndividualRequest ir2 = fakeIndividualRequest(getUri(ID2));
MultiplexedRequestContent expectedRequests = new MultiplexedRequestContent();
expectedRequests.setRequests(new IndividualRequestMap(ImmutableMap.of("0", ir1, "1", ir2)));
assertMultiplexedRequestContentEquals(multiplexedRequest.getContent(), expectedRequests);
verifyCallbacks(multiplexedRequest);
}
use of com.linkedin.restli.common.multiplexer.MultiplexedRequestContent in project rest.li by linkedin.
the class TestMultiplexedRequestBuilder method testBody.
@Test
public void testBody() throws IOException {
TestRecord entity = fakeEntity(0);
CreateRequest<TestRecord> request = fakeCreateRequest(entity);
NoOpCallback<EmptyRecord> callback = new NoOpCallback<EmptyRecord>();
MultiplexedRequest multiplexedRequest = MultiplexedRequestBuilder.createSequentialRequest().addRequest(request, callback).build();
IndividualRequest individualRequest = new IndividualRequest().setMethod(HttpMethod.POST.name()).setHeaders(new StringMap(HEADERS)).setRelativeUrl(BASE_URI).setBody(new IndividualBody(entity.data()));
MultiplexedRequestContent expectedRequests = new MultiplexedRequestContent();
expectedRequests.setRequests(new IndividualRequestMap(ImmutableMap.of("0", individualRequest)));
assertMultiplexedRequestContentEquals(multiplexedRequest.getContent(), expectedRequests);
}
use of com.linkedin.restli.common.multiplexer.MultiplexedRequestContent in project rest.li by linkedin.
the class TestAsyncMethodInvocationPlanClass method muxRestRequest.
private RestRequest muxRestRequest(Map<String, IndividualRequest> requests) throws URISyntaxException, IOException {
MultiplexedRequestContent content = new MultiplexedRequestContent();
content.setRequests(new IndividualRequestMap(requests));
return muxRequestBuilder().setMethod(HttpMethod.POST.name()).setEntity(CODEC.mapToBytes(content.data())).setHeader(RestConstants.HEADER_CONTENT_TYPE, RestConstants.HEADER_VALUE_APPLICATION_JSON).build();
}
use of com.linkedin.restli.common.multiplexer.MultiplexedRequestContent in project rest.li by linkedin.
the class MultiplexedRequestBuilder method toMultiplexedRequest.
private static MultiplexedRequest toMultiplexedRequest(IndividualRequestMap individualRequests, Map<Integer, Callback<RestResponse>> callbacks) {
MultiplexedRequestContent multiplexedRequestContent = new MultiplexedRequestContent();
multiplexedRequestContent.setRequests(individualRequests);
return new MultiplexedRequest(multiplexedRequestContent, callbacks);
}
use of com.linkedin.restli.common.multiplexer.MultiplexedRequestContent in project rest.li by linkedin.
the class TestMultiplexedRequestHandlerImpl method fakeMuxRestRequest.
private static RestRequest fakeMuxRestRequest(Map<String, IndividualRequest> requests) throws URISyntaxException, IOException {
MultiplexedRequestContent content = new MultiplexedRequestContent();
content.setRequests(new IndividualRequestMap(requests));
return muxRequestBuilder().setMethod(HttpMethod.POST.name()).setEntity(CODEC.mapToBytes(content.data())).setHeader(RestConstants.HEADER_CONTENT_TYPE, RestConstants.HEADER_VALUE_APPLICATION_JSON).build();
}
Aggregations