Search in sources :

Example 1 with BatchGreetingRequestBuilders

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

the class TestMaxBatchSize method testBatchGetWithMaxBatchSizeBeyondLimitation.

@Test
public void testBatchGetWithMaxBatchSizeBeyondLimitation() throws RemoteInvocationException {
    BatchGetEntityRequest<Long, Greeting> request = new BatchGreetingRequestBuilders().batchGet().ids(1l, 2l, 3l).build();
    try {
        getClient().sendRequest(request).getResponse();
        Assert.fail("The batch size is larger than the allowed max batch size should cause an exception.");
    } catch (RestLiResponseException e) {
        Assert.assertEquals(e.getStatus(), HttpStatus.S_400_BAD_REQUEST.getCode());
        Assert.assertEquals(e.getServiceErrorMessage(), "The request batch size: " + "3 is larger than the allowed max batch size: 2 for method: batch_get");
    }
}
Also used : Greeting(com.linkedin.restli.examples.greetings.api.Greeting) RestLiResponseException(com.linkedin.restli.client.RestLiResponseException) BatchGreetingRequestBuilders(com.linkedin.restli.examples.greetings.client.BatchGreetingRequestBuilders) Test(org.testng.annotations.Test)

Example 2 with BatchGreetingRequestBuilders

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

the class TestMaxBatchSize method testBatchGetWithMaxBatchSizeUnderLimitation.

@Test
public void testBatchGetWithMaxBatchSizeUnderLimitation() throws RemoteInvocationException {
    BatchGetEntityRequest<Long, Greeting> request = new BatchGreetingRequestBuilders().batchGet().ids(1l, 2l).build();
    Response<BatchKVResponse<Long, EntityResponse<Greeting>>> response = getClient().sendRequest(request).getResponse();
    Assert.assertEquals(response.getStatus(), 200);
    Assert.assertEquals(response.getEntity().getResults().keySet().size(), 2);
}
Also used : Greeting(com.linkedin.restli.examples.greetings.api.Greeting) BatchKVResponse(com.linkedin.restli.client.response.BatchKVResponse) BatchGreetingRequestBuilders(com.linkedin.restli.examples.greetings.client.BatchGreetingRequestBuilders) Test(org.testng.annotations.Test)

Aggregations

Greeting (com.linkedin.restli.examples.greetings.api.Greeting)2 BatchGreetingRequestBuilders (com.linkedin.restli.examples.greetings.client.BatchGreetingRequestBuilders)2 Test (org.testng.annotations.Test)2 RestLiResponseException (com.linkedin.restli.client.RestLiResponseException)1 BatchKVResponse (com.linkedin.restli.client.response.BatchKVResponse)1