use of com.linkedin.restli.common.EntityResponse in project rest.li by linkedin.
the class TestRestLiScatterGather method testSendSGGetEntityRequests.
// BatchGetEntityRequest
private static void testSendSGGetEntityRequests(RestClient restClient, Long[] requestIds) throws RemoteInvocationException {
BatchGetEntityRequest<Long, Greeting> request = new GreetingsRequestBuilders().batchGet().ids(requestIds).fields(Greeting.fields().message()).setParam("foo", "bar").build();
BatchKVResponse<Long, EntityResponse<Greeting>> result = restClient.sendRequest(request).getResponse().getEntity();
Assert.assertEquals(result.getResults().size(), requestIds.length);
EntityResponse<Greeting> item = result.getResults().values().iterator().next();
Assert.assertNotNull(item.getEntity());
Assert.assertNotNull(item.getEntity().getMessage());
Assert.assertTrue(result.getResults().values().iterator().next().getEntity() instanceof Greeting);
Assert.assertEquals(result.getErrors().size(), 0);
}
use of com.linkedin.restli.common.EntityResponse in project rest.li by linkedin.
the class TestAssociationsResource method testBatchGetEntity.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestOptionsDataProvider")
public void testBatchGetEntity(RestliRequestOptions requestOptions) throws RemoteInvocationException {
Request<BatchKVResponse<CompoundKey, EntityResponse<Message>>> request = new AssociationsRequestBuilders(requestOptions).batchGet().ids(DB.keySet()).build();
ResponseFuture<BatchKVResponse<CompoundKey, EntityResponse<Message>>> responseFuture = getClient().sendRequest(request);
Response<BatchKVResponse<CompoundKey, EntityResponse<Message>>> response = responseFuture.getResponse();
BatchKVResponse<CompoundKey, EntityResponse<Message>> entityResponse = response.getEntity();
Assert.assertEquals(entityResponse.getErrors().size(), 0);
Assert.assertEquals(entityResponse.getResults().size(), 2);
for (CompoundKey id : DB.keySet()) {
EntityResponse<Message> single = entityResponse.getResults().get(id);
Assert.assertTrue(entityResponse.getResults().containsKey(id));
Assert.assertEquals(single.getEntity(), DB.get(id));
}
}
Aggregations