use of com.linkedin.restli.server.PagingContext in project rest.li by linkedin.
the class TestRestLiMethodInvocation method testPromiseFinderOptionalBooleanParam.
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "statusFinderOptionalBooleanParam")
public void testPromiseFinderOptionalBooleanParam(ProtocolVersion version, String query) throws Exception {
ResourceModel statusResourceModel = buildResourceModel(PromiseStatusCollectionResource.class);
ResourceMethodDescriptor methodDescriptor = statusResourceModel.findNamedMethod("user_timeline");
PromiseStatusCollectionResource statusResource = getMockResource(PromiseStatusCollectionResource.class);
EasyMock.expect(statusResource.getUserTimeline(eq(false), (PagingContext) EasyMock.anyObject())).andReturn(Promises.<List<Status>>value(null)).once();
checkInvocation(statusResource, methodDescriptor, "GET", version, "/promiseStatuses" + query);
}
use of com.linkedin.restli.server.PagingContext in project rest.li by linkedin.
the class TestRestLiMethodInvocation method testAsyncGetAllComplexKeyResource.
@Test
public void testAsyncGetAllComplexKeyResource() throws Exception {
ResourceModel discoveredResourceModel = buildResourceModel(AsyncDiscoveredItemsResource.class);
RestLiCallback<?> callback = getCallback();
ResourceMethodDescriptor methodDescriptor;
AsyncDiscoveredItemsResource discoveredResource;
methodDescriptor = discoveredResourceModel.findMethod(ResourceMethod.GET_ALL);
discoveredResource = getMockResource(AsyncDiscoveredItemsResource.class);
@SuppressWarnings("unchecked") PagingContext mockCtx = (PagingContext) EasyMock.anyObject();
discoveredResource.getAll(mockCtx, EasyMock.<Callback<List<DiscoveredItem>>>anyObject());
EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
@Override
public Object answer() throws Throwable {
@SuppressWarnings("unchecked") Callback<List<DiscoveredItem>> callback = (Callback<List<DiscoveredItem>>) EasyMock.getCurrentArguments()[1];
callback.onSuccess(null);
return null;
}
});
EasyMock.replay(discoveredResource);
checkAsyncInvocation(discoveredResource, callback, methodDescriptor, "GET", version, "/asyncdiscovereditems", buildBatchPathKeys());
}
use of com.linkedin.restli.server.PagingContext in project rest.li by linkedin.
the class TestRestLiMethodInvocation method testPromisePagingContextUserTimelineStartAndCount.
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "statusUserTimelineStartAndCount")
public void testPromisePagingContextUserTimelineStartAndCount(ProtocolVersion version, String query) throws Exception {
ResourceModel statusResourceModel = buildResourceModel(PromiseStatusCollectionResource.class);
ResourceMethodDescriptor methodDescriptor = statusResourceModel.findNamedMethod("user_timeline");
PromiseStatusCollectionResource statusResource = getMockResource(PromiseStatusCollectionResource.class);
EasyMock.expect(statusResource.getUserTimeline(eq(true), eq(new PagingContext(0, 20, true, true)))).andReturn(Promises.<List<Status>>value(null)).once();
checkInvocation(statusResource, methodDescriptor, "GET", version, "/promisestatuses" + query);
}
use of com.linkedin.restli.server.PagingContext in project rest.li by linkedin.
the class TestCollectionArgumentBuilder method testProjectionParams.
@Test
public void testProjectionParams() {
List<Parameter<?>> finderWithProjectionParams = new ArrayList<Parameter<?>>();
finderWithProjectionParams.add(new Parameter<String>("key", String.class, new StringDataSchema(), false, null, Parameter.ParamType.QUERY, true, new AnnotationSet(new Annotation[] {})));
finderWithProjectionParams.add(new Parameter<PagingContext>("", PagingContext.class, null, false, new PagingContext(0, 10), Parameter.ParamType.PAGING_CONTEXT_PARAM, false, new AnnotationSet(new Annotation[] {})));
finderWithProjectionParams.add(new Parameter<MaskTree>("", MaskTree.class, null, false, null, Parameter.ParamType.PROJECTION_PARAM, false, new AnnotationSet(new Annotation[] {})));
finderWithProjectionParams.add(new Parameter<MaskTree>("", MaskTree.class, null, false, null, Parameter.ParamType.METADATA_PROJECTION_PARAM, false, new AnnotationSet(new Annotation[] {})));
finderWithProjectionParams.add(new Parameter<MaskTree>("", MaskTree.class, null, false, null, Parameter.ParamType.PAGING_PROJECTION_PARAM, false, new AnnotationSet(new Annotation[] {})));
Map<String, String> finderWithProjectionContextParams = new HashMap<String, String>();
finderWithProjectionContextParams.put("start", "100");
finderWithProjectionContextParams.put("count", "15");
finderWithProjectionContextParams.put("key", "keyString");
Map<String, Integer> projectionMap = new HashMap<String, Integer>();
projectionMap.put("a", 1);
Map<String, Integer> metadataMap = new HashMap<String, Integer>();
metadataMap.put("intField", 1);
metadataMap.put("booleanField", 1);
Map<String, Integer> pagingMap = new HashMap<String, Integer>();
pagingMap.put("total", 1);
MaskTree projectionMask = new MaskTree(new DataMap(projectionMap));
MaskTree metadataMask = new MaskTree(new DataMap(metadataMap));
MaskTree pagingMask = new MaskTree(new DataMap(pagingMap));
Object[] expectedArgs = new Object[] { "keyString", new PagingContext(100, 15), projectionMask, metadataMask, pagingMask };
ResourceMethodDescriptor descriptor = RestLiArgumentBuilderTestHelper.getMockResourceMethodDescriptor(null, 1, finderWithProjectionParams);
ResourceContext context = RestLiArgumentBuilderTestHelper.getMockResourceContext(finderWithProjectionContextParams, projectionMask, metadataMask, pagingMask, true);
RoutingResult routingResult = RestLiArgumentBuilderTestHelper.getMockRoutingResult(descriptor, 1, context, 1);
RestRequest request = RestLiArgumentBuilderTestHelper.getMockRequest(false, null, 0);
RestLiArgumentBuilder argumentBuilder = new CollectionArgumentBuilder();
RestLiRequestData requestData = argumentBuilder.extractRequestData(routingResult, request);
Object[] args = argumentBuilder.buildArguments(requestData, routingResult);
assertEquals(args, expectedArgs);
verify(descriptor, context, routingResult, request);
}
Aggregations