use of com.linkedin.restli.client.response.BatchKVResponse in project rest.li by linkedin.
the class TestCompressionServer method testNewCookbookInBatch.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "clientsCookbookDataProvider")
public void testNewCookbookInBatch(RestClient client, RestliRequestOptions requestOptions) throws Exception {
final GreetingsRequestBuilders builders = new GreetingsRequestBuilders(requestOptions);
// GET
Greeting greetingResult = getNewCookbookBatchGetResult(client, requestOptions);
// POST
Greeting greeting = new Greeting(greetingResult.data().copy());
greeting.setMessage("This is a new message!");
Request<BatchKVResponse<Long, UpdateStatus>> writeRequest = builders.batchUpdate().input(1L, greeting).build();
client.sendRequest(writeRequest).getResponse();
// GET again, to verify that our POST worked.
getNewCookbookBatchGetResult(client, requestOptions);
// batch Create
Greeting repeatedGreeting = new Greeting();
repeatedGreeting.setMessage("Hello Hello");
repeatedGreeting.setTone(Tone.SINCERE);
List<Greeting> entities = Arrays.asList(repeatedGreeting, repeatedGreeting);
Request<BatchCreateIdResponse<Long>> batchCreateRequest = builders.batchCreate().inputs(entities).build();
List<CreateIdStatus<Long>> statuses = client.sendRequest(batchCreateRequest).getResponse().getEntity().getElements();
for (CreateIdStatus<Long> status : statuses) {
Assert.assertEquals(status.getStatus().intValue(), HttpStatus.S_201_CREATED.getCode());
@SuppressWarnings("deprecation") String id = status.getId();
Assert.assertEquals(status.getKey().longValue(), Long.parseLong(id));
Assert.assertNotNull(status.getKey());
}
}
use of com.linkedin.restli.client.response.BatchKVResponse in project rest.li by linkedin.
the class TestCompressionServer method testOldCookbookInBatch.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "clientsCookbookDataProvider")
public void testOldCookbookInBatch(RestClient client, RestliRequestOptions requestOptions) throws Exception {
final GreetingsBuilders builders = new GreetingsBuilders(requestOptions);
// GET
Greeting greetingResult = getOldCookbookBatchGetResult(client, requestOptions);
// POST
Greeting greeting = new Greeting(greetingResult.data().copy());
greeting.setMessage("This is a new message!");
Request<BatchKVResponse<Long, UpdateStatus>> writeRequest = builders.batchUpdate().input(1L, greeting).build();
client.sendRequest(writeRequest).getResponse();
// GET again, to verify that our POST worked.
getOldCookbookBatchGetResult(client, requestOptions);
// batch Create
Greeting repeatedGreeting = new Greeting();
repeatedGreeting.setMessage("Hello Hello");
repeatedGreeting.setTone(Tone.SINCERE);
List<Greeting> entities = Arrays.asList(repeatedGreeting, repeatedGreeting);
Request<CollectionResponse<CreateStatus>> batchCreateRequest = builders.batchCreate().inputs(entities).build();
List<CreateStatus> statuses = client.sendRequest(batchCreateRequest).getResponse().getEntity().getElements();
for (CreateStatus status : statuses) {
Assert.assertEquals(status.getStatus().intValue(), HttpStatus.S_201_CREATED.getCode());
@SuppressWarnings("deprecation") String id = status.getId();
Assert.assertNotNull(id);
}
}
use of com.linkedin.restli.client.response.BatchKVResponse in project rest.li by linkedin.
the class TestComplexArrayResource method testBatchGetEntity.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "versionWithRequestOptionsDataProvider")
public void testBatchGetEntity(ProtocolVersion version, RestliRequestOptions options) throws RemoteInvocationException {
List<ComplexResourceKey<ComplexArray, ComplexArray>> complexKeys = getBatchCompleKeys();
ComplexArrayRequestBuilders builders = new ComplexArrayRequestBuilders(options);
Request<BatchKVResponse<ComplexResourceKey<ComplexArray, ComplexArray>, EntityResponse<Greeting>>> request2 = builders.batchGet().ids(complexKeys).build();
Response<BatchKVResponse<ComplexResourceKey<ComplexArray, ComplexArray>, EntityResponse<Greeting>>> response2 = getClient().sendRequest(request2).getResponse();
EntityResponse<Greeting> greeting1 = response2.getEntity().getResults().get(complexKeys.get(0));
Assert.assertNotNull(greeting1);
EntityResponse<Greeting> greeting2 = response2.getEntity().getResults().get(complexKeys.get(1));
Assert.assertNotNull(greeting2);
}
use of com.linkedin.restli.client.response.BatchKVResponse in project rest.li by linkedin.
the class TestComplexArrayResource method testBatchGetKV.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "versionWithRequestOptionsDataProvider")
public void testBatchGetKV(ProtocolVersion version, RestliRequestOptions options) throws RemoteInvocationException {
List<ComplexResourceKey<ComplexArray, ComplexArray>> complexKeys = getBatchCompleKeys();
ComplexArrayBuilders builders = new ComplexArrayBuilders(options);
Request<BatchKVResponse<ComplexResourceKey<ComplexArray, ComplexArray>, Greeting>> request2 = builders.batchGet().ids(complexKeys).buildKV();
Response<BatchKVResponse<ComplexResourceKey<ComplexArray, ComplexArray>, Greeting>> response2 = getClient().sendRequest(request2).getResponse();
Greeting greeting1 = response2.getEntity().getResults().get(complexKeys.get(0));
Assert.assertNotNull(greeting1);
Greeting greeting2 = response2.getEntity().getResults().get(complexKeys.get(1));
Assert.assertNotNull(greeting2);
}
use of com.linkedin.restli.client.response.BatchKVResponse in project rest.li by linkedin.
the class TestEscapeCharsInStringKeys method testBatchGetEntityWithSimpleKey.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestStringKeysOptionsDataProvider")
public void testBatchGetEntityWithSimpleKey(RestliRequestOptions requestOptions) throws Exception {
Set<String> keys = new HashSet<String>();
keys.add(key1());
keys.add(key2());
Request<BatchKVResponse<String, EntityResponse<Message>>> req = new StringKeysRequestBuilders(requestOptions).batchGet().ids(keys).build();
BatchKVResponse<String, EntityResponse<Message>> response = getClient().sendRequest(req).get().getEntity();
Map<String, EntityResponse<Message>> results = response.getResults();
Assert.assertEquals(results.get(key1()).getEntity().getMessage(), key1(), "Message should match key for key1");
Assert.assertEquals(results.get(key2()).getEntity().getMessage(), key2(), "Message should match key for key2");
}
Aggregations