Search in sources :

Example 1 with AssociationsRequestBuilders

use of com.linkedin.restli.examples.greetings.client.AssociationsRequestBuilders 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));
    }
}
Also used : Message(com.linkedin.restli.examples.greetings.api.Message) CompoundKey(com.linkedin.restli.common.CompoundKey) EntityResponse(com.linkedin.restli.common.EntityResponse) AssociationsRequestBuilders(com.linkedin.restli.examples.greetings.client.AssociationsRequestBuilders) BatchKVResponse(com.linkedin.restli.client.response.BatchKVResponse) Test(org.testng.annotations.Test)

Aggregations

BatchKVResponse (com.linkedin.restli.client.response.BatchKVResponse)1 CompoundKey (com.linkedin.restli.common.CompoundKey)1 EntityResponse (com.linkedin.restli.common.EntityResponse)1 Message (com.linkedin.restli.examples.greetings.api.Message)1 AssociationsRequestBuilders (com.linkedin.restli.examples.greetings.client.AssociationsRequestBuilders)1 Test (org.testng.annotations.Test)1