use of com.linkedin.restli.server.BatchDeleteRequest in project rest.li by linkedin.
the class TestRestLiMethodInvocation method testAsyncBatchDeleteAssociativeResource.
@Test
public void testAsyncBatchDeleteAssociativeResource() throws Exception {
ResourceModel followsResourceModel = buildResourceModel(AsyncFollowsAssociativeResource.class);
RestLiCallback<?> callback = getCallback();
ResourceMethodDescriptor methodDescriptor;
AsyncFollowsAssociativeResource resource;
methodDescriptor = followsResourceModel.findMethod(ResourceMethod.BATCH_DELETE);
resource = getMockResource(AsyncFollowsAssociativeResource.class);
@SuppressWarnings("unchecked") BatchDeleteRequest<CompoundKey, Followed> mockBatchDeleteReq = (BatchDeleteRequest<CompoundKey, Followed>) EasyMock.anyObject();
resource.batchDelete(mockBatchDeleteReq, 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);
String uri = "/asyncfollows?ids=List((followeeID:2,followerID:1),(followeeID:4,followerID:3),(followeeID:6,followerID:5))";
checkAsyncInvocation(resource, callback, methodDescriptor, "DELETE", version, uri, buildBatchPathKeys(buildFollowsCompoundKey(1L, 2L), buildFollowsCompoundKey(3L, 4L), buildFollowsCompoundKey(5L, 6L)));
}
use of com.linkedin.restli.server.BatchDeleteRequest in project rest.li by linkedin.
the class TestRestLiMethodInvocation method testPromiseBatchDelete.
@Test
@SuppressWarnings({ "unchecked" })
public void testPromiseBatchDelete() throws Exception {
ResourceModel statusResourceModel = buildResourceModel(PromiseStatusCollectionResource.class);
ResourceModel discoveredItemsResourceModel = buildResourceModel(PromiseDiscoveredItemsResource.class);
ResourceMethodDescriptor methodDescriptor;
PromiseStatusCollectionResource statusResource;
PromiseDiscoveredItemsResource discoveredItemsResource;
// #1 Batch delete on collection resource
methodDescriptor = statusResourceModel.findMethod(ResourceMethod.BATCH_DELETE);
statusResource = getMockResource(PromiseStatusCollectionResource.class);
@SuppressWarnings("rawtypes") BatchDeleteRequest batchDeleteRequest = (BatchDeleteRequest) EasyMock.anyObject();
EasyMock.expect(statusResource.batchDelete(batchDeleteRequest)).andReturn(Promises.<BatchUpdateResult<Long, Status>>value(null)).once();
checkInvocation(statusResource, methodDescriptor, "DELETE", version, "/promisestatuses?ids=List(1,2)", "", buildBatchPathKeys(1L, 2L));
// #2 Batch delete on complex-key resource
methodDescriptor = discoveredItemsResourceModel.findMethod(ResourceMethod.BATCH_DELETE);
discoveredItemsResource = getMockResource(PromiseDiscoveredItemsResource.class);
ComplexResourceKey<DiscoveredItemKey, DiscoveredItemKeyParams> keyA = getDiscoveredItemComplexKey(1L, 2, 3L);
ComplexResourceKey<DiscoveredItemKey, DiscoveredItemKeyParams> keyB = getDiscoveredItemComplexKey(4L, 5, 6L);
batchDeleteRequest = (BatchDeleteRequest) EasyMock.anyObject();
EasyMock.expect(discoveredItemsResource.batchDelete(batchDeleteRequest)).andReturn(Promises.<BatchUpdateResult<ComplexResourceKey<DiscoveredItemKey, DiscoveredItemKeyParams>, DiscoveredItem>>value(null)).once();
checkInvocation(discoveredItemsResource, methodDescriptor, "DELETE", version, "/promisediscovereditems?ids=List((itemId:1,type:2,userId:3),(itemId:4,type:5,userId:6))", "", buildBatchPathKeys(keyA, keyB));
}
use of com.linkedin.restli.server.BatchDeleteRequest in project rest.li by linkedin.
the class TestBatchDeleteArgumentBuilder method testArgumentBuilderSuccess.
@Test(dataProvider = "argumentData")
public void testArgumentBuilderSuccess(Set<Object> batchKeys) {
@SuppressWarnings("rawtypes") Parameter<Set> param = new Parameter<Set>("", Set.class, null, false, null, Parameter.ParamType.BATCH, false, new AnnotationSet(new Annotation[] {}));
ResourceMethodDescriptor descriptor = RestLiArgumentBuilderTestHelper.getMockResourceMethodDescriptor(null, param);
ResourceContext context = RestLiArgumentBuilderTestHelper.getMockResourceContext(null, null, batchKeys, true);
RoutingResult routingResult = RestLiArgumentBuilderTestHelper.getMockRoutingResult(descriptor, 1, context, 2);
RestRequest request = RestLiArgumentBuilderTestHelper.getMockRequest(false, null, 0);
RestLiArgumentBuilder argumentBuilder = new BatchDeleteArgumentBuilder();
RestLiRequestData requestData = argumentBuilder.extractRequestData(routingResult, request);
Object[] args = argumentBuilder.buildArguments(requestData, routingResult);
assertEquals(args.length, 1);
assertTrue(args[0] instanceof BatchDeleteRequest);
assertEquals(((BatchDeleteRequest) args[0]).getKeys(), batchKeys);
verify(descriptor, context, routingResult, request);
}
Aggregations