Search in sources :

Example 1 with TyperefKeysRequestBuilders

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

the class TestTyperefKeysResource method testCreateId.

@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestOptionsDataProvider")
public void testCreateId(RestliRequestOptions requestOptions) throws RemoteInvocationException {
    Greeting greeting = new Greeting().setId(1L).setMessage("Foo").setTone(Tone.FRIENDLY);
    CreateIdRequest<Long, Greeting> req = new TyperefKeysRequestBuilders(requestOptions).create().input(greeting).build();
    Response<IdResponse<Long>> resp = getClient().sendRequest(req).getResponse();
    Assert.assertEquals(resp.getEntity().getId(), Long.valueOf(1L));
}
Also used : Greeting(com.linkedin.restli.examples.greetings.api.Greeting) IdResponse(com.linkedin.restli.common.IdResponse) TyperefKeysRequestBuilders(com.linkedin.restli.examples.greetings.client.TyperefKeysRequestBuilders) Test(org.testng.annotations.Test)

Example 2 with TyperefKeysRequestBuilders

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

the class TestTyperefKeysResource method testBatchGetEntity.

@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestOptionsDataProvider")
public void testBatchGetEntity(RestliRequestOptions requestOptions) throws RemoteInvocationException {
    BatchGetEntityRequest<Long, Greeting> req = new TyperefKeysRequestBuilders(requestOptions).batchGet().ids(1L, 2L).build();
    Response<BatchKVResponse<Long, EntityResponse<Greeting>>> resp = getClient().sendRequest(req).getResponse();
    Map<Long, EntityResponse<Greeting>> results = resp.getEntity().getResults();
    Assert.assertEquals(results.get(1L).getEntity().getId(), Long.valueOf(1L));
    Assert.assertEquals(results.get(2L).getEntity().getId(), Long.valueOf(2L));
}
Also used : Greeting(com.linkedin.restli.examples.greetings.api.Greeting) EntityResponse(com.linkedin.restli.common.EntityResponse) TyperefKeysRequestBuilders(com.linkedin.restli.examples.greetings.client.TyperefKeysRequestBuilders) BatchKVResponse(com.linkedin.restli.client.response.BatchKVResponse) Test(org.testng.annotations.Test)

Aggregations

Greeting (com.linkedin.restli.examples.greetings.api.Greeting)2 TyperefKeysRequestBuilders (com.linkedin.restli.examples.greetings.client.TyperefKeysRequestBuilders)2 Test (org.testng.annotations.Test)2 BatchKVResponse (com.linkedin.restli.client.response.BatchKVResponse)1 EntityResponse (com.linkedin.restli.common.EntityResponse)1 IdResponse (com.linkedin.restli.common.IdResponse)1