Search in sources :

Example 1 with MultiplexedRequestContent

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);
}
Also used : IndividualRequest(com.linkedin.restli.common.multiplexer.IndividualRequest) IndividualRequestMap(com.linkedin.restli.common.multiplexer.IndividualRequestMap) MultiplexedRequestContent(com.linkedin.restli.common.multiplexer.MultiplexedRequestContent) Test(org.testng.annotations.Test)

Example 2 with MultiplexedRequestContent

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);
}
Also used : EmptyRecord(com.linkedin.restli.common.EmptyRecord) IndividualRequest(com.linkedin.restli.common.multiplexer.IndividualRequest) IndividualRequestMap(com.linkedin.restli.common.multiplexer.IndividualRequestMap) StringMap(com.linkedin.data.template.StringMap) IndividualBody(com.linkedin.restli.common.multiplexer.IndividualBody) MultiplexedRequestContent(com.linkedin.restli.common.multiplexer.MultiplexedRequestContent) TestRecord(com.linkedin.restli.client.test.TestRecord) Test(org.testng.annotations.Test)

Example 3 with MultiplexedRequestContent

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();
}
Also used : IndividualRequestMap(com.linkedin.restli.common.multiplexer.IndividualRequestMap) MultiplexedRequestContent(com.linkedin.restli.common.multiplexer.MultiplexedRequestContent)

Example 4 with MultiplexedRequestContent

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);
}
Also used : MultiplexedRequestContent(com.linkedin.restli.common.multiplexer.MultiplexedRequestContent)

Example 5 with MultiplexedRequestContent

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();
}
Also used : IndividualRequestMap(com.linkedin.restli.common.multiplexer.IndividualRequestMap) MultiplexedRequestContent(com.linkedin.restli.common.multiplexer.MultiplexedRequestContent)

Aggregations

MultiplexedRequestContent (com.linkedin.restli.common.multiplexer.MultiplexedRequestContent)8 IndividualRequestMap (com.linkedin.restli.common.multiplexer.IndividualRequestMap)7 IndividualRequest (com.linkedin.restli.common.multiplexer.IndividualRequest)3 Test (org.testng.annotations.Test)3 DataMap (com.linkedin.data.DataMap)1 StringMap (com.linkedin.data.template.StringMap)1 TestRecord (com.linkedin.restli.client.test.TestRecord)1 EmptyRecord (com.linkedin.restli.common.EmptyRecord)1 IndividualBody (com.linkedin.restli.common.multiplexer.IndividualBody)1