use of com.linkedin.restli.server.BatchDeleteRequest in project rest.li by linkedin.
the class TestRestLiMethodInvocation method testAsyncBatchDelete.
@Test
public void testAsyncBatchDelete() throws Exception {
ResourceModel statusResourceModel = buildResourceModel(AsyncStatusCollectionResource.class);
RestLiCallback<?> callback = getCallback();
ResourceMethodDescriptor methodDescriptor;
AsyncStatusCollectionResource statusResource;
methodDescriptor = statusResourceModel.findMethod(ResourceMethod.BATCH_DELETE);
statusResource = getMockResource(AsyncStatusCollectionResource.class);
@SuppressWarnings("unchecked") BatchDeleteRequest<Long, Status> mockBatchDeleteReq = (BatchDeleteRequest<Long, Status>) EasyMock.anyObject();
statusResource.batchDelete(mockBatchDeleteReq, 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, "DELETE", version, "/asyncstatuses?ids=List(1,2,3)", buildBatchPathKeys(1L, 2L, 3L));
}
use of com.linkedin.restli.server.BatchDeleteRequest in project rest.li by linkedin.
the class BatchDeleteArgumentBuilder method buildArguments.
@Override
public Object[] buildArguments(RestLiRequestData requestData, RoutingResult routingResult) {
@SuppressWarnings({ "unchecked", "rawtypes" }) BatchDeleteRequest batchRequest = new BatchDeleteRequest(new HashSet(requestData.getBatchKeys()));
Object[] positionalArgs = { batchRequest };
return ArgumentBuilder.buildArgs(positionalArgs, routingResult.getResourceMethod(), routingResult.getContext(), null);
}
use of com.linkedin.restli.server.BatchDeleteRequest in project rest.li by linkedin.
the class TestRestLiMethodInvocation method testAsyncBatchDeleteComplexResource.
@Test
public void testAsyncBatchDeleteComplexResource() throws Exception {
ResourceModel discoveredResourceModel = buildResourceModel(AsyncDiscoveredItemsResource.class);
RestLiCallback<?> callback = getCallback();
ResourceMethodDescriptor methodDescriptor;
AsyncDiscoveredItemsResource discoveredResource;
methodDescriptor = discoveredResourceModel.findMethod(ResourceMethod.BATCH_DELETE);
discoveredResource = getMockResource(AsyncDiscoveredItemsResource.class);
@SuppressWarnings("unchecked") BatchDeleteRequest<ComplexResourceKey<DiscoveredItemKey, DiscoveredItemKeyParams>, DiscoveredItem> mockBatchDeleteReq = (BatchDeleteRequest<ComplexResourceKey<DiscoveredItemKey, DiscoveredItemKeyParams>, DiscoveredItem>) EasyMock.anyObject();
discoveredResource.batchDelete(mockBatchDeleteReq, EasyMock.<Callback<BatchUpdateResult<ComplexResourceKey<DiscoveredItemKey, DiscoveredItemKeyParams>, DiscoveredItem>>>anyObject());
EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
@Override
public Object answer() throws Throwable {
@SuppressWarnings("unchecked") Callback<BatchUpdateResult<ComplexResourceKey<DiscoveredItemKey, DiscoveredItemKeyParams>, DiscoveredItem>> callback = (Callback<BatchUpdateResult<ComplexResourceKey<DiscoveredItemKey, DiscoveredItemKeyParams>, DiscoveredItem>>) EasyMock.getCurrentArguments()[1];
callback.onSuccess(null);
return null;
}
});
EasyMock.replay(discoveredResource);
String uri = "/asyncdiscovereditems?ids=List((itemId:1,type:1,userId:1),(itemId:2,type:2,userId:2),(itemId:3,type:3,userId:3))";
checkAsyncInvocation(discoveredResource, callback, methodDescriptor, "DELETE", version, uri, buildBatchPathKeys(getDiscoveredItemComplexKey(1, 1, 1), getDiscoveredItemComplexKey(2, 2, 2), getDiscoveredItemComplexKey(3, 3, 3)));
}
use of com.linkedin.restli.server.BatchDeleteRequest in project rest.li by linkedin.
the class TestRestLiMethodInvocation method testCustomCrudParamsCollectionBatchDelete.
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "paramCollectionBatchDelete")
public void testCustomCrudParamsCollectionBatchDelete(ProtocolVersion version, String uri) throws Exception {
ResourceModel model = buildResourceModel(CombinedResources.CollectionWithCustomCrudParams.class);
ResourceMethodDescriptor methodDescriptor = model.findMethod(ResourceMethod.BATCH_DELETE);
CombinedResources.CollectionWithCustomCrudParams resource = getMockResource(CombinedResources.CollectionWithCustomCrudParams.class);
@SuppressWarnings("rawtypes") BatchDeleteRequest batchDeleteRequest = (BatchDeleteRequest) EasyMock.anyObject();
@SuppressWarnings("unchecked") BatchUpdateResult<String, CombinedTestDataModels.Foo> batchUpdateResult = resource.myBatchDelete(batchDeleteRequest, eq(1), eq("baz"));
EasyMock.expect(batchUpdateResult).andReturn(null).once();
checkInvocation(resource, methodDescriptor, "DELETE", version, uri, "", buildBatchPathKeys("foo", "bar"));
}
use of com.linkedin.restli.server.BatchDeleteRequest in project rest.li by linkedin.
the class TestRestLiMethodInvocation method testBatchDelete.
@Test
@SuppressWarnings({ "unchecked" })
public void testBatchDelete() throws Exception {
ResourceModel statusResourceModel = buildResourceModel(StatusCollectionResource.class);
ResourceModel discoveredItemsResourceModel = buildResourceModel(DiscoveredItemsResource.class);
ResourceMethodDescriptor methodDescriptor;
StatusCollectionResource statusResource;
DiscoveredItemsResource discoveredItemsResource;
// #1 Batch delete on collection resource
methodDescriptor = statusResourceModel.findMethod(ResourceMethod.BATCH_DELETE);
statusResource = getMockResource(StatusCollectionResource.class);
@SuppressWarnings("rawtypes") BatchDeleteRequest batchDeleteRequest = (BatchDeleteRequest) EasyMock.anyObject();
EasyMock.expect(statusResource.batchDelete(batchDeleteRequest)).andReturn(null).once();
checkInvocation(statusResource, methodDescriptor, "DELETE", version, "/statuses?ids=List(1,2)", "", buildBatchPathKeys(1L, 2L));
// #2 Batch delete on complex-key resource
methodDescriptor = discoveredItemsResourceModel.findMethod(ResourceMethod.BATCH_DELETE);
discoveredItemsResource = getMockResource(DiscoveredItemsResource.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(null).once();
String uri = "/discovereditems?ids=List((itemId:1,type:2,userId:3),(itemId:4,type:5,userId:6))";
checkInvocation(discoveredItemsResource, methodDescriptor, "DELETE", version, uri, buildBatchPathKeys(keyA, keyB));
}
Aggregations