use of com.linkedin.restli.common.CompoundKey in project rest.li by linkedin.
the class TestBatchUpdateResponseBuilder method unsupportedNullKeyMapData.
@DataProvider(name = "unsupportedNullKeyMapData")
public Object[][] unsupportedNullKeyMapData() {
final CompoundKey c1 = new CompoundKey().append("a", "a1").append("b", 1);
final Map<CompoundKey, UpdateResponse> results = new ConcurrentHashMap<CompoundKey, UpdateResponse>();
results.put(c1, new UpdateResponse(HttpStatus.S_202_ACCEPTED));
final BatchUpdateResult<CompoundKey, Foo> batchUpdateResult = new BatchUpdateResult<CompoundKey, Foo>(results, new ConcurrentHashMap<CompoundKey, RestLiServiceException>());
final UpdateStatus updateStatus = new UpdateStatus().setStatus(202);
final Map<String, UpdateStatus> expectedProtocol1Results = new HashMap<String, UpdateStatus>();
expectedProtocol1Results.put("a=a1&b=1", updateStatus);
final Map<String, UpdateStatus> expectedProtocol2Results = new HashMap<String, UpdateStatus>();
expectedProtocol2Results.put("(a:a1,b:1)", updateStatus);
return new Object[][] { { batchUpdateResult, AllProtocolVersions.RESTLI_PROTOCOL_1_0_0.getProtocolVersion(), expectedProtocol1Results }, { batchUpdateResult, AllProtocolVersions.RESTLI_PROTOCOL_2_0_0.getProtocolVersion(), expectedProtocol2Results } };
}
use of com.linkedin.restli.common.CompoundKey in project rest.li by linkedin.
the class TestRestLiMethodInvocation method testDataMapToCompoundKey.
@Test(dataProvider = "dataMapToCompoundKey")
public void testDataMapToCompoundKey(CompoundKey expectedCompoundKey, DataMap dataMap, Set<Key> keys) {
CompoundKey compoundKey = ArgumentUtils.dataMapToCompoundKey(dataMap, keys);
Assert.assertEquals(compoundKey, expectedCompoundKey);
}
use of com.linkedin.restli.common.CompoundKey in project rest.li by linkedin.
the class TestRestLiMethodInvocation method buildFollowsCompoundKey.
/**
* Helper method to return a Compound Key for the FollowsAssociativeResource and AsyncFollowsAssociativeResource
* Sets the "followerID" to id1
* Sets the "followeeID" to id2
*
* @param id1 the "followerID".
* @param id2 the "followeeID"
*
* @return
*/
private CompoundKey buildFollowsCompoundKey(Long id1, Long id2) {
CompoundKey key = new CompoundKey();
key.append("followerID", id1);
key.append("followeeID", id2);
return key;
}
use of com.linkedin.restli.common.CompoundKey in project rest.li by linkedin.
the class TestRestLiMethodInvocation method testAsyncBatchUpdateAssociativeResource.
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "batchUpdateCompoundKey")
public void testAsyncBatchUpdateAssociativeResource(ProtocolVersion version, String uri, String body) throws Exception {
ResourceModel followsResourceModel = buildResourceModel(AsyncFollowsAssociativeResource.class);
RestLiCallback<?> callback = getCallback();
ResourceMethodDescriptor methodDescriptor;
AsyncFollowsAssociativeResource resource;
methodDescriptor = followsResourceModel.findMethod(ResourceMethod.BATCH_UPDATE);
resource = getMockResource(AsyncFollowsAssociativeResource.class);
@SuppressWarnings("unchecked") BatchUpdateRequest<CompoundKey, Followed> mockBatchUpdateReq = (BatchUpdateRequest<CompoundKey, Followed>) EasyMock.anyObject();
resource.batchUpdate(mockBatchUpdateReq, EasyMock.<Callback<BatchUpdateResult<CompoundKey, Followed>>>anyObject());
EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
@Override
public Object answer() throws Throwable {
@SuppressWarnings("unchecked") Callback<BatchUpdateResult<CompoundKey, Followed>> callback = (Callback<BatchUpdateResult<CompoundKey, Followed>>) EasyMock.getCurrentArguments()[1];
callback.onSuccess(null);
return null;
}
});
EasyMock.replay(resource);
checkAsyncInvocation(resource, callback, methodDescriptor, "PUT", version, uri, body, buildBatchPathKeys(buildFollowsCompoundKey(1L, 2L), buildFollowsCompoundKey(3L, 4L), buildFollowsCompoundKey(5L, 6L)));
}
use of com.linkedin.restli.common.CompoundKey in project rest.li by linkedin.
the class TestRestLiMethodInvocation method testPromiseGetAssociativeResource.
@Test
public void testPromiseGetAssociativeResource() throws Exception {
ResourceModel followsResourceModel = buildResourceModel(PromiseFollowsAssociativeResource.class);
ResourceMethodDescriptor methodDescriptor;
PromiseFollowsAssociativeResource resource;
// #1: get
methodDescriptor = followsResourceModel.findMethod(ResourceMethod.GET);
resource = getMockResource(PromiseFollowsAssociativeResource.class);
CompoundKey rawKey = new CompoundKey();
rawKey.append("followerID", 1L);
rawKey.append("followeeID", 2L);
CompoundKey key = eq(rawKey);
EasyMock.expect(resource.get(key)).andReturn(Promises.value(new Followed(new DataMap()))).once();
checkInvocation(resource, methodDescriptor, "GET", version, "/promisefollows/(followerID:1,followeeID:2)", buildPathKeys("followerID", 1L, "followeeID", 2L, followsResourceModel.getKeyName(), rawKey));
}
Aggregations