Search in sources :

Example 1 with StringKeysBuilders

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

the class TestEscapeCharsInStringKeys method testBatchGetWithSimpleKey.

@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestStringKeysOptionsDataProvider")
public void testBatchGetWithSimpleKey(RestliRequestOptions requestOptions) throws Exception {
    Set<String> keys = new HashSet<String>();
    keys.add(key1());
    keys.add(key2());
    Request<BatchResponse<Message>> req = new StringKeysBuilders(requestOptions).batchGet().ids(keys).build();
    BatchResponse<Message> response = getClient().sendRequest(req).get().getEntity();
    Map<String, Message> results = response.getResults();
    Assert.assertEquals(results.get(key1()).getMessage(), key1(), "Message should match key for key1");
    Assert.assertEquals(results.get(key2()).getMessage(), key2(), "Message should match key for key2");
}
Also used : Message(com.linkedin.restli.examples.greetings.api.Message) StringKeysBuilders(com.linkedin.restli.examples.greetings.client.StringKeysBuilders) BatchResponse(com.linkedin.restli.common.BatchResponse) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 2 with StringKeysBuilders

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

the class TestEscapeCharsInStringKeys method testBatchGetKVWithSimpleKey.

@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestStringKeysOptionsDataProvider")
public void testBatchGetKVWithSimpleKey(RestliRequestOptions requestOptions) throws Exception {
    Set<String> keys = new HashSet<String>();
    keys.add(key1());
    keys.add(key2());
    Request<BatchKVResponse<String, Message>> req = new StringKeysBuilders(requestOptions).batchGet().ids(keys).buildKV();
    BatchKVResponse<String, Message> response = getClient().sendRequest(req).get().getEntity();
    Map<String, Message> results = response.getResults();
    Assert.assertEquals(results.get(key1()).getMessage(), key1(), "Message should match key for key1");
    Assert.assertEquals(results.get(key2()).getMessage(), key2(), "Message should match key for key2");
}
Also used : Message(com.linkedin.restli.examples.greetings.api.Message) StringKeysBuilders(com.linkedin.restli.examples.greetings.client.StringKeysBuilders) BatchKVResponse(com.linkedin.restli.client.response.BatchKVResponse) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Aggregations

Message (com.linkedin.restli.examples.greetings.api.Message)2 StringKeysBuilders (com.linkedin.restli.examples.greetings.client.StringKeysBuilders)2 HashSet (java.util.HashSet)2 Test (org.testng.annotations.Test)2 BatchKVResponse (com.linkedin.restli.client.response.BatchKVResponse)1 BatchResponse (com.linkedin.restli.common.BatchResponse)1