use of com.linkedin.restli.internal.server.RestLiCallback in project rest.li by linkedin.
the class TestRestLiMethodInvocation method testAsyncBatchUpdate.
@Test
public void testAsyncBatchUpdate() throws Exception {
ResourceModel statusResourceModel = buildResourceModel(AsyncStatusCollectionResource.class);
RestLiCallback<?> callback = getCallback();
ResourceMethodDescriptor methodDescriptor;
AsyncStatusCollectionResource statusResource;
methodDescriptor = statusResourceModel.findMethod(ResourceMethod.BATCH_UPDATE);
statusResource = getMockResource(AsyncStatusCollectionResource.class);
@SuppressWarnings("unchecked") BatchUpdateRequest<Long, Status> mockBatchUpdateReq = (BatchUpdateRequest<Long, Status>) EasyMock.anyObject();
statusResource.batchUpdate(mockBatchUpdateReq, EasyMock.<Callback<BatchUpdateResult<Long, Status>>>anyObject());
EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
@Override
public Object answer() throws Throwable {
@SuppressWarnings("unchecked") Callback<BatchCreateResult<Long, Status>> callback = (Callback<BatchCreateResult<Long, Status>>) EasyMock.getCurrentArguments()[1];
callback.onSuccess(null);
return null;
}
});
EasyMock.replay(statusResource);
checkAsyncInvocation(statusResource, callback, methodDescriptor, "PUT", version, "/asyncstatuses?ids=List(1,2,3)", "{\"entities\": {\"1\": {}, \"2\": {}, \"3\": {}}}", buildBatchPathKeys(1L, 2L, 3L));
}
use of com.linkedin.restli.internal.server.RestLiCallback in project rest.li by linkedin.
the class TestRestLiMethodInvocation method testAsyncGetAllComplexKeyResource.
@Test
public void testAsyncGetAllComplexKeyResource() throws Exception {
ResourceModel discoveredResourceModel = buildResourceModel(AsyncDiscoveredItemsResource.class);
RestLiCallback<?> callback = getCallback();
ResourceMethodDescriptor methodDescriptor;
AsyncDiscoveredItemsResource discoveredResource;
methodDescriptor = discoveredResourceModel.findMethod(ResourceMethod.GET_ALL);
discoveredResource = getMockResource(AsyncDiscoveredItemsResource.class);
@SuppressWarnings("unchecked") PagingContext mockCtx = (PagingContext) EasyMock.anyObject();
discoveredResource.getAll(mockCtx, EasyMock.<Callback<List<DiscoveredItem>>>anyObject());
EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
@Override
public Object answer() throws Throwable {
@SuppressWarnings("unchecked") Callback<List<DiscoveredItem>> callback = (Callback<List<DiscoveredItem>>) EasyMock.getCurrentArguments()[1];
callback.onSuccess(null);
return null;
}
});
EasyMock.replay(discoveredResource);
checkAsyncInvocation(discoveredResource, callback, methodDescriptor, "GET", version, "/asyncdiscovereditems", buildBatchPathKeys());
}
use of com.linkedin.restli.internal.server.RestLiCallback in project rest.li by linkedin.
the class TestRestLiMethodInvocation method testAsyncGetAssociativeResource.
@Test
public void testAsyncGetAssociativeResource() throws Exception {
ResourceModel followsResourceModel = buildResourceModel(AsyncFollowsAssociativeResource.class);
RestLiCallback<?> callback = getCallback();
ResourceMethodDescriptor methodDescriptor;
AsyncFollowsAssociativeResource resource;
// #1: get
methodDescriptor = followsResourceModel.findMethod(ResourceMethod.GET);
resource = getMockResource(AsyncFollowsAssociativeResource.class);
CompoundKey rawKey = new CompoundKey();
rawKey.append("followerID", 1L);
rawKey.append("followeeID", 2L);
CompoundKey key = eq(rawKey);
resource.get(key, EasyMock.<Callback<Followed>>anyObject());
EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
@Override
public Object answer() throws Throwable {
@SuppressWarnings("unchecked") Callback<Followed> callback = (Callback<Followed>) EasyMock.getCurrentArguments()[1];
callback.onSuccess(null);
return null;
}
});
EasyMock.replay(resource);
checkAsyncInvocation(resource, callback, methodDescriptor, "GET", version, "/asyncfollows/(followerID:1,followeeID:2)", buildPathKeys("followerID", 1L, "followeeID", 2L, followsResourceModel.getKeyName(), rawKey));
}
use of com.linkedin.restli.internal.server.RestLiCallback in project rest.li by linkedin.
the class TestRestLiMethodInvocation method testAsyncFinderOptionalParam.
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "statusFinderOptionalParam")
public void testAsyncFinderOptionalParam(ProtocolVersion version, String query) throws Exception {
RestLiCallback<?> callback = getCallback();
ResourceModel statusResourceModel = buildResourceModel(AsyncStatusCollectionResource.class);
ResourceMethodDescriptor methodDescriptor = statusResourceModel.findNamedMethod("search");
AsyncStatusCollectionResource statusResource = getMockResource(AsyncStatusCollectionResource.class);
statusResource.search((PagingContext) EasyMock.anyObject(), eq("linkedin"), eq(-1L), eq((StatusType) null), EasyMock.<Callback<List<Status>>>anyObject());
EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
@Override
public Object answer() throws Throwable {
@SuppressWarnings("unchecked") Callback<List<Status>> callback = (Callback<List<Status>>) EasyMock.getCurrentArguments()[4];
callback.onSuccess(null);
return null;
}
});
EasyMock.replay(statusResource);
checkAsyncInvocation(statusResource, callback, methodDescriptor, "GET", version, "/asyncstatuses" + query, null);
}
use of com.linkedin.restli.internal.server.RestLiCallback in project rest.li by linkedin.
the class TestRestLiMethodInvocation method testAsyncBatchPatchAssociativeResource.
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "batchUpdateCompoundKey")
public void testAsyncBatchPatchAssociativeResource(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_PARTIAL_UPDATE);
resource = getMockResource(AsyncFollowsAssociativeResource.class);
@SuppressWarnings("unchecked") BatchPatchRequest<CompoundKey, Followed> mockBatchPatchReq = (BatchPatchRequest<CompoundKey, Followed>) EasyMock.anyObject();
resource.batchUpdate(mockBatchPatchReq, 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, "POST", version, uri, body, buildBatchPathKeys(buildFollowsCompoundKey(1L, 2L), buildFollowsCompoundKey(3L, 4L), buildFollowsCompoundKey(5L, 6L)));
}
Aggregations