Search in sources :

Example 61 with ResourceMethodDescriptor

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);
}
Also used : PromiseRepliesCollectionResource(com.linkedin.restli.server.twitter.PromiseRepliesCollectionResource) RepliesCollectionResource(com.linkedin.restli.server.twitter.RepliesCollectionResource) AsyncRepliesCollectionResource(com.linkedin.restli.server.twitter.AsyncRepliesCollectionResource) ResourceMethodDescriptor(com.linkedin.restli.internal.server.model.ResourceMethodDescriptor) ResourceModel(com.linkedin.restli.internal.server.model.ResourceModel) RestLiTestHelper.buildResourceModel(com.linkedin.restli.server.test.RestLiTestHelper.buildResourceModel) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest) BeforeTest(org.testng.annotations.BeforeTest)

Example 62 with ResourceMethodDescriptor

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);
}
Also used : PromiseRepliesCollectionResource(com.linkedin.restli.server.twitter.PromiseRepliesCollectionResource) RepliesCollectionResource(com.linkedin.restli.server.twitter.RepliesCollectionResource) AsyncRepliesCollectionResource(com.linkedin.restli.server.twitter.AsyncRepliesCollectionResource) ResourceMethodDescriptor(com.linkedin.restli.internal.server.model.ResourceMethodDescriptor) ResourceModel(com.linkedin.restli.internal.server.model.ResourceModel) RestLiTestHelper.buildResourceModel(com.linkedin.restli.server.test.RestLiTestHelper.buildResourceModel) CustomLong(com.linkedin.restli.server.custom.types.CustomLong) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest) BeforeTest(org.testng.annotations.BeforeTest)

Example 63 with ResourceMethodDescriptor

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());
}
Also used : Callback(com.linkedin.common.callback.Callback) RestLiCallback(com.linkedin.restli.internal.server.RestLiCallback) FilterChainCallback(com.linkedin.restli.internal.server.filter.FilterChainCallback) RequestExecutionCallback(com.linkedin.restli.server.RequestExecutionCallback) ResourceMethodDescriptor(com.linkedin.restli.internal.server.model.ResourceMethodDescriptor) Followed(com.linkedin.restli.server.twitter.TwitterTestDataModels.Followed) ResourceModel(com.linkedin.restli.internal.server.model.ResourceModel) RestLiTestHelper.buildResourceModel(com.linkedin.restli.server.test.RestLiTestHelper.buildResourceModel) List(java.util.List) EasyMock.anyObject(org.easymock.EasyMock.anyObject) AsyncFollowsAssociativeResource(com.linkedin.restli.server.twitter.AsyncFollowsAssociativeResource) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest) BeforeTest(org.testng.annotations.BeforeTest)

Example 64 with ResourceMethodDescriptor

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);
}
Also used : PromiseStatusCollectionResource(com.linkedin.restli.server.twitter.PromiseStatusCollectionResource) ResourceMethodDescriptor(com.linkedin.restli.internal.server.model.ResourceMethodDescriptor) ResourceModel(com.linkedin.restli.internal.server.model.ResourceModel) RestLiTestHelper.buildResourceModel(com.linkedin.restli.server.test.RestLiTestHelper.buildResourceModel) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest) BeforeTest(org.testng.annotations.BeforeTest)

Example 65 with ResourceMethodDescriptor

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());
}
Also used : BatchCreateRequest(com.linkedin.restli.server.BatchCreateRequest) ResourceMethodDescriptor(com.linkedin.restli.internal.server.model.ResourceMethodDescriptor) ResourceModel(com.linkedin.restli.internal.server.model.ResourceModel) RestLiTestHelper.buildResourceModel(com.linkedin.restli.server.test.RestLiTestHelper.buildResourceModel) TaskStatusCollectionResource(com.linkedin.restli.server.twitter.TaskStatusCollectionResource) StatusCollectionResource(com.linkedin.restli.server.twitter.StatusCollectionResource) AsyncStatusCollectionResource(com.linkedin.restli.server.twitter.AsyncStatusCollectionResource) CustomStatusCollectionResource(com.linkedin.restli.server.twitter.CustomStatusCollectionResource) PromiseStatusCollectionResource(com.linkedin.restli.server.twitter.PromiseStatusCollectionResource) AsyncDiscoveredItemsResource(com.linkedin.restli.server.twitter.AsyncDiscoveredItemsResource) PromiseDiscoveredItemsResource(com.linkedin.restli.server.twitter.PromiseDiscoveredItemsResource) DiscoveredItemsResource(com.linkedin.restli.server.twitter.DiscoveredItemsResource) ByteString(com.linkedin.data.ByteString) CustomString(com.linkedin.restli.server.custom.types.CustomString) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

ResourceMethodDescriptor (com.linkedin.restli.internal.server.model.ResourceMethodDescriptor)195 Test (org.testng.annotations.Test)171 ResourceModel (com.linkedin.restli.internal.server.model.ResourceModel)140 RestLiTestHelper.buildResourceModel (com.linkedin.restli.server.test.RestLiTestHelper.buildResourceModel)116 AfterTest (org.testng.annotations.AfterTest)105 BeforeTest (org.testng.annotations.BeforeTest)105 RoutingResult (com.linkedin.restli.internal.server.RoutingResult)66 PromiseStatusCollectionResource (com.linkedin.restli.server.twitter.PromiseStatusCollectionResource)47 RestRequest (com.linkedin.r2.message.rest.RestRequest)41 ByteString (com.linkedin.data.ByteString)40 AsyncStatusCollectionResource (com.linkedin.restli.server.twitter.AsyncStatusCollectionResource)38 ResourceContext (com.linkedin.restli.server.ResourceContext)37 CustomString (com.linkedin.restli.server.custom.types.CustomString)37 ServerResourceContext (com.linkedin.restli.internal.server.ServerResourceContext)31 RestLiCallback (com.linkedin.restli.internal.server.RestLiCallback)27 FilterChainCallback (com.linkedin.restli.internal.server.filter.FilterChainCallback)27 EasyMock.anyObject (org.easymock.EasyMock.anyObject)27 Callback (com.linkedin.common.callback.Callback)26 RequestExecutionCallback (com.linkedin.restli.server.RequestExecutionCallback)26 CustomStatusCollectionResource (com.linkedin.restli.server.twitter.CustomStatusCollectionResource)26