Search in sources :

Example 1 with TyperefKeysBuilders

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

the class TestTyperefKeysResource method testBatchGet.

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

Example 2 with TyperefKeysBuilders

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

the class TestTyperefKeysResource method testBatchGetKV.

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

Example 3 with TyperefKeysBuilders

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

the class TestTyperefKeysResource method testCreate.

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

Aggregations

Greeting (com.linkedin.restli.examples.greetings.api.Greeting)3 TyperefKeysBuilders (com.linkedin.restli.examples.greetings.client.TyperefKeysBuilders)3 Test (org.testng.annotations.Test)3 BatchKVResponse (com.linkedin.restli.client.response.BatchKVResponse)1 BatchResponse (com.linkedin.restli.common.BatchResponse)1 EmptyRecord (com.linkedin.restli.common.EmptyRecord)1