use of com.linkedin.restli.client.response.BatchKVResponse in project rest.li by linkedin.
the class TestGroupsClient method testAssociationBatchGetKVCompoundKeyResponse.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestOptionsDataProvider")
public void testAssociationBatchGetKVCompoundKeyResponse(RestliRequestOptions requestOptions) throws RemoteInvocationException {
CompoundKey key1 = buildCompoundKey(1, 1);
CompoundKey key2 = buildCompoundKey(2, 1);
Set<CompoundKey> allRequestedKeys = new HashSet<CompoundKey>(Arrays.asList(key1, key2));
Request<BatchKVResponse<CompoundKey, GroupMembership>> request = new GroupMembershipsBuilders(requestOptions).batchGet().ids(key1, key2).fields(GroupMembership.fields().contactEmail()).buildKV();
BatchKVResponse<CompoundKey, GroupMembership> groupMemberships = getClient().sendRequest(request).getResponse().getEntity();
Assert.assertTrue(allRequestedKeys.containsAll(groupMemberships.getResults().keySet()));
Assert.assertTrue(allRequestedKeys.containsAll(groupMemberships.getErrors().keySet()));
Set<CompoundKey> allResponseKeys = new HashSet<CompoundKey>(groupMemberships.getResults().keySet());
allResponseKeys.addAll(groupMemberships.getErrors().keySet());
Assert.assertEquals(allResponseKeys, allRequestedKeys);
}
use of com.linkedin.restli.client.response.BatchKVResponse in project rest.li by linkedin.
the class TestCustomTypesClient method testBatchUpdateForChainedRefs.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestChainedTyperefsBuilderDataProvider")
public void testBatchUpdateForChainedRefs(RootBuilderWrapper<CompoundKey, Greeting> builders) throws RemoteInvocationException {
Long lo = 29L;
Long date = 10L;
ChainedTyperefsBuilders.Key key = new ChainedTyperefsBuilders.Key().setAge(new CustomNonNegativeLong(lo)).setBirthday(new Date(date));
RequestBuilder<? extends Request<BatchKVResponse<CompoundKey, UpdateStatus>>> batchUpdateRequest = builders.batchUpdate().input(key, new Greeting().setId(1).setMessage("foo")).getBuilder();
BatchKVResponse<CompoundKey, UpdateStatus> response = getClient().sendRequest(batchUpdateRequest).getResponse().getEntity();
Assert.assertEquals(1, response.getResults().keySet().size());
CompoundKey expected = new CompoundKey();
expected.append("birthday", new Date(date));
expected.append("age", new CustomNonNegativeLong(lo));
CompoundKey result = response.getResults().keySet().iterator().next();
Assert.assertEquals(result, expected);
}
use of com.linkedin.restli.client.response.BatchKVResponse in project rest.li by linkedin.
the class TestCustomTypesClient method testCollectionBatchGetKV.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestOptionsDataProvider")
public void testCollectionBatchGetKV(RestliRequestOptions requestOptions) throws RemoteInvocationException {
Request<BatchKVResponse<CustomLong, Greeting>> request = new CustomTypes2Builders(requestOptions).batchGet().ids(new CustomLong(1L), new CustomLong(2L), new CustomLong(3L)).buildKV();
Map<CustomLong, Greeting> greetings = getClient().sendRequest(request).getResponse().getEntity().getResults();
Assert.assertEquals(greetings.size(), 3);
Assert.assertEquals(greetings.get(new CustomLong(1L)).getId().longValue(), 1L);
Assert.assertEquals(greetings.get(new CustomLong(2L)).getId().longValue(), 2L);
Assert.assertEquals(greetings.get(new CustomLong(3L)).getId().longValue(), 3L);
}
use of com.linkedin.restli.client.response.BatchKVResponse in project rest.li by linkedin.
the class TestCustomTypesClient method testCollectionBatchPartialUpdate.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "request2BuilderDataProvider")
public void testCollectionBatchPartialUpdate(RootBuilderWrapper<CustomLong, Greeting> builders) throws RemoteInvocationException {
RequestBuilder<? extends Request<BatchKVResponse<CustomLong, UpdateStatus>>> request = builders.batchPartialUpdate().input(new CustomLong(1L), new PatchRequest<Greeting>()).input(new CustomLong(2L), new PatchRequest<Greeting>()).getBuilder();
Map<CustomLong, UpdateStatus> statuses = getClient().sendRequest(request).getResponse().getEntity().getResults();
Assert.assertEquals(statuses.size(), 2);
Assert.assertEquals(statuses.get(new CustomLong(1L)).getStatus().intValue(), HttpStatus.S_204_NO_CONTENT.getCode());
Assert.assertEquals(statuses.get(new CustomLong(2L)).getStatus().intValue(), HttpStatus.S_204_NO_CONTENT.getCode());
}
use of com.linkedin.restli.client.response.BatchKVResponse in project rest.li by linkedin.
the class TestCustomTypesClient method testCollectionBatchUpdate.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "request2BuilderDataProvider")
public void testCollectionBatchUpdate(RootBuilderWrapper<CustomLong, Greeting> builders) throws RemoteInvocationException {
RequestBuilder<? extends Request<BatchKVResponse<CustomLong, UpdateStatus>>> request = builders.batchUpdate().input(new CustomLong(1L), new Greeting().setId(1)).input(new CustomLong(2L), new Greeting().setId(2)).getBuilder();
Map<CustomLong, UpdateStatus> statuses = getClient().sendRequest(request).getResponse().getEntity().getResults();
Assert.assertEquals(statuses.size(), 2);
Assert.assertEquals(statuses.get(new CustomLong(1L)).getStatus().intValue(), HttpStatus.S_204_NO_CONTENT.getCode());
Assert.assertEquals(statuses.get(new CustomLong(2L)).getStatus().intValue(), HttpStatus.S_204_NO_CONTENT.getCode());
}
Aggregations