use of com.linkedin.restli.internal.server.model.ResourceMethodDescriptor in project rest.li by linkedin.
the class TestRestLiMethodInvocation method testCustomTypeParameters_WrongType.
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "customTypeWrongType")
public void testCustomTypeParameters_WrongType(ProtocolVersion version, String uri) throws Exception {
ResourceModel repliesResourceModel = buildResourceModel(RepliesCollectionResource.class);
ResourceMethodDescriptor methodDescriptor = repliesResourceModel.findNamedMethod("customLong");
expectRoutingException(methodDescriptor, getMockResource(RepliesCollectionResource.class), "GET", uri, version);
}
use of com.linkedin.restli.internal.server.model.ResourceMethodDescriptor in project rest.li by linkedin.
the class TestRestLiMethodInvocation method testCustomTypeParametersCustomLong.
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "customLongParam")
public void testCustomTypeParametersCustomLong(ProtocolVersion version, String uri) throws Exception {
ResourceModel repliesResourceModel = buildResourceModel(RepliesCollectionResource.class);
ResourceMethodDescriptor methodDescriptor = repliesResourceModel.findNamedMethod("customLong");
RepliesCollectionResource repliesResource = getMockResource(RepliesCollectionResource.class);
repliesResource.customLong(new CustomLong(100L));
EasyMock.expectLastCall().andReturn(null).once();
checkInvocation(repliesResource, methodDescriptor, "GET", version, uri);
}
use of com.linkedin.restli.internal.server.model.ResourceMethodDescriptor in project rest.li by linkedin.
the class TestRestLiMethodInvocation method testAsyncGetAllAssociativeResource.
@Test
public void testAsyncGetAllAssociativeResource() throws Exception {
ResourceModel followsResourceModel = buildResourceModel(AsyncFollowsAssociativeResource.class);
RestLiCallback<?> callback = getCallback();
ResourceMethodDescriptor methodDescriptor;
AsyncFollowsAssociativeResource resource;
methodDescriptor = followsResourceModel.findMethod(ResourceMethod.GET_ALL);
resource = getMockResource(AsyncFollowsAssociativeResource.class);
resource.getAll((PagingContext) EasyMock.anyObject(), EasyMock.<Callback<List<Followed>>>anyObject());
EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
@Override
public Object answer() throws Throwable {
@SuppressWarnings("unchecked") Callback<List<Followed>> callback = (Callback<List<Followed>>) EasyMock.getCurrentArguments()[1];
callback.onSuccess(null);
return null;
}
});
EasyMock.replay(resource);
checkAsyncInvocation(resource, callback, methodDescriptor, "GET", version, "/asyncfollows", buildBatchPathKeys());
}
use of com.linkedin.restli.internal.server.model.ResourceMethodDescriptor in project rest.li by linkedin.
the class TestRestLiMethodInvocation method testPromisePagingContextNegativeCount.
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "statusPagingContextNegativeCount")
public void testPromisePagingContextNegativeCount(ProtocolVersion version, String query) throws Exception {
ResourceModel statusResourceModel = buildResourceModel(PromiseStatusCollectionResource.class);
ResourceMethodDescriptor methodDescriptor = statusResourceModel.findNamedMethod("public_timeline");
PromiseStatusCollectionResource statusResource = getMockResource(PromiseStatusCollectionResource.class);
expectRoutingException(methodDescriptor, statusResource, "GET", "/promisestatuses" + query, version);
}
use of com.linkedin.restli.internal.server.model.ResourceMethodDescriptor in project rest.li by linkedin.
the class TestRestLiMethodInvocation method testBatchCreate.
@Test
@SuppressWarnings({ "unchecked" })
public void testBatchCreate() throws Exception {
ResourceModel statusResourceModel = buildResourceModel(StatusCollectionResource.class);
ResourceModel discoveredItemsResourceModel = buildResourceModel(DiscoveredItemsResource.class);
ResourceMethodDescriptor methodDescriptor;
StatusCollectionResource statusResource;
DiscoveredItemsResource discoveredItemsResource;
// #1 Batch create on collection resource
methodDescriptor = statusResourceModel.findMethod(ResourceMethod.BATCH_CREATE);
statusResource = getMockResource(StatusCollectionResource.class);
@SuppressWarnings("rawtypes") BatchCreateRequest batchCreateRequest = (BatchCreateRequest) EasyMock.anyObject();
EasyMock.expect(statusResource.batchCreate(batchCreateRequest)).andReturn(null).once();
String body = RestLiTestHelper.doubleQuote("{'elements':[{},{}]}");
checkInvocation(statusResource, methodDescriptor, "POST", version, "/statuses", body, buildBatchPathKeys());
// #2 Batch create on complex-key resource
methodDescriptor = discoveredItemsResourceModel.findMethod(ResourceMethod.BATCH_CREATE);
discoveredItemsResource = getMockResource(DiscoveredItemsResource.class);
batchCreateRequest = (BatchCreateRequest) EasyMock.anyObject();
EasyMock.expect(discoveredItemsResource.batchCreate(batchCreateRequest)).andReturn(null).once();
checkInvocation(discoveredItemsResource, methodDescriptor, "POST", version, "/discovereditems", body, buildBatchPathKeys());
}
Aggregations