use of com.linkedin.restli.internal.server.model.ResourceMethodDescriptor in project rest.li by linkedin.
the class TestRestLiMethodInvocation method testPromiseFinderError.
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "promiseFinderError")
public void testPromiseFinderError(ProtocolVersion version, String uri) throws Exception {
ResourceModel statusResourceModel = buildResourceModel(PromiseStatusCollectionResource.class);
ResourceMethodDescriptor methodDescriptor = statusResourceModel.findNamedMethod("search");
PromiseStatusCollectionResource statusResource = getMockResource(PromiseStatusCollectionResource.class);
expectRoutingException(methodDescriptor, statusResource, "GET", uri, version);
}
use of com.linkedin.restli.internal.server.model.ResourceMethodDescriptor in project rest.li by linkedin.
the class TestRestLiMethodInvocation method testCustomCrudParamsCollectionBatchUpdate.
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "paramCollectionBatchUpdate")
public void testCustomCrudParamsCollectionBatchUpdate(ProtocolVersion version, String uri, String body) throws Exception {
ResourceModel model = buildResourceModel(CombinedResources.CollectionWithCustomCrudParams.class);
ResourceMethodDescriptor methodDescriptor = model.findMethod(ResourceMethod.BATCH_UPDATE);
CombinedResources.CollectionWithCustomCrudParams resource = getMockResource(CombinedResources.CollectionWithCustomCrudParams.class);
@SuppressWarnings("rawtypes") BatchUpdateRequest batchUpdateRequest = (BatchUpdateRequest) EasyMock.anyObject();
@SuppressWarnings("unchecked") BatchUpdateResult<String, CombinedTestDataModels.Foo> batchUpdateResult = resource.myBatchUpdate(batchUpdateRequest, eq(1), eq("baz"));
EasyMock.expect(batchUpdateResult).andReturn(null).once();
checkInvocation(resource, methodDescriptor, "PUT", version, uri, body, buildBatchPathKeys("foo", "bar"));
}
use of com.linkedin.restli.internal.server.model.ResourceMethodDescriptor in project rest.li by linkedin.
the class TestRestLiResourceModels method testTwitterAsyncStatusModel.
@Test
public void testTwitterAsyncStatusModel() throws Exception {
ResourceModel statusResourceModel = buildResourceModel(AsyncStatusCollectionResource.class);
checkCollectionModel(statusResourceModel, "asyncstatuses", Long.class, "statusID", Status.class, false, AsyncStatusCollectionResource.class);
assertHasMethods(statusResourceModel, ResourceMethod.CREATE, ResourceMethod.FINDER, ResourceMethod.BATCH_GET);
ResourceMethodDescriptor methodDescriptor;
methodDescriptor = checkFinderMethod(statusResourceModel, "public_timeline", 2);
methodDescriptor = checkFinderMethod(statusResourceModel, "user_timeline", 3);
methodDescriptor = checkFinderMethod(statusResourceModel, "search", 5);
checkParam(methodDescriptor, "keywords", String.class, null);
checkParam(methodDescriptor, "since", long.class, -1L);
checkParam(methodDescriptor, "type", StatusType.class, null);
assertNull(methodDescriptor.getParameter("foo"));
assertNull(statusResourceModel.findActionMethod("foo", ResourceLevel.COLLECTION));
assertNotNull(statusResourceModel.findMethod(ResourceMethod.BATCH_GET));
assertNotNull(statusResourceModel.findMethod(ResourceMethod.CREATE));
assertNotNull(statusResourceModel.findMethod(ResourceMethod.BATCH_CREATE));
assertNotNull(statusResourceModel.findMethod(ResourceMethod.BATCH_DELETE));
checkEntityModel(statusResourceModel, Long.class, "statusID", Status.class, Collections.<String, Class<?>>emptyMap());
assertNotNull(statusResourceModel.findMethod(ResourceMethod.GET));
assertNotNull(statusResourceModel.findMethod(ResourceMethod.PARTIAL_UPDATE));
assertNotNull(statusResourceModel.findMethod(ResourceMethod.FINDER));
assertNotNull(statusResourceModel.findMethod(ResourceMethod.BATCH_UPDATE));
assertNotNull(statusResourceModel.findMethod(ResourceMethod.BATCH_PARTIAL_UPDATE));
assertNotNull(statusResourceModel.findMethod(ResourceMethod.GET_ALL));
}
use of com.linkedin.restli.internal.server.model.ResourceMethodDescriptor in project rest.li by linkedin.
the class TestRestLiResourceModels method testTwitterStatusModel.
@Test
public void testTwitterStatusModel() throws Exception {
ResourceModel statusResourceModel = buildResourceModel(StatusCollectionResource.class);
checkCollectionModel(statusResourceModel, "statuses", Long.class, "statusID", Status.class, false, StatusCollectionResource.class);
assertHasMethods(statusResourceModel, ResourceMethod.CREATE, ResourceMethod.FINDER, ResourceMethod.BATCH_GET);
ResourceMethodDescriptor methodDescriptor;
methodDescriptor = checkFinderMethod(statusResourceModel, "public_timeline", 1);
methodDescriptor = checkFinderMethod(statusResourceModel, "user_timeline", 2);
methodDescriptor = checkFinderMethod(statusResourceModel, "search", 3);
checkParam(methodDescriptor, "keywords", String.class, null);
checkParam(methodDescriptor, "since", long.class, -1L);
checkParam(methodDescriptor, "type", StatusType.class, null);
assertNull(methodDescriptor.getParameter("foo"));
assertNull(statusResourceModel.findActionMethod("foo", ResourceLevel.COLLECTION));
assertNotNull(statusResourceModel.findMethod(ResourceMethod.BATCH_GET));
assertNotNull(statusResourceModel.findMethod(ResourceMethod.CREATE));
assertNotNull(statusResourceModel.findMethod(ResourceMethod.BATCH_CREATE));
checkEntityModel(statusResourceModel, Long.class, "statusID", Status.class, Collections.<String, Class<?>>emptyMap());
assertNotNull(statusResourceModel.findMethod(ResourceMethod.GET));
assertNotNull(statusResourceModel.findMethod(ResourceMethod.PARTIAL_UPDATE));
assertNotNull(statusResourceModel.findMethod(ResourceMethod.FINDER));
assertNotNull(statusResourceModel.findMethod(ResourceMethod.BATCH_UPDATE));
}
use of com.linkedin.restli.internal.server.model.ResourceMethodDescriptor in project rest.li by linkedin.
the class TestRestLiResourceModels method testExceptionMethods.
@Test
public void testExceptionMethods() throws Exception {
final ResourceModel resourceModel = buildResourceModel(ExceptionsResource.class);
assertEquals(resourceModel.getResourceType(), ResourceType.COLLECTION);
assertEquals(resourceModel.getResourceMethodDescriptors().size(), 2);
final ResourceMethodDescriptor getMethod = resourceModel.findMethod(ResourceMethod.GET);
assertNotNull(getMethod);
final ResourceMethodDescriptor actionMethod = resourceModel.findActionMethod("exception", ResourceLevel.COLLECTION);
assertNotNull(actionMethod);
final Class<?> returnClass = actionMethod.getActionReturnType();
assertSame(returnClass, Integer.class);
}
Aggregations