Package com.linkedin.restli.internal.server.filter

Examples of com.linkedin.restli.internal.server.filter.FilterRequestContextInternal


    MethodAdapterRegistry mockRegistry = createMock(MethodAdapterRegistry.class);
    RestLiArgumentBuilder mockBuilder = createMock(RestLiArgumentBuilder.class);
    RequestFilter mockFilter = createMock(RequestFilter.class);
    @SuppressWarnings("unchecked")
    RequestExecutionCallback<Object> mockCallback = createMock(RequestExecutionCallback.class);
    FilterRequestContextInternal mockFilterContext = createMock(FilterRequestContextInternal.class);
    RestLiRequestData requestData = new RestLiRequestDataImpl.Builder().key("Key").build();
    RestLiMethodInvoker invokerWithFilters =
        new RestLiMethodInvoker(_resourceFactory,
                                _engine,
                                new ErrorResponseBuilder(),
                                mockRegistry,
                                Arrays.asList(mockFilter, mockFilter));
    Map<String, ResourceModel> resourceModelMap =
        buildResourceModels(StatusCollectionResource.class, LocationResource.class, DiscoveredItemsResource.class);
    ResourceModel statusResourceModel = resourceModelMap.get("/statuses");
    ResourceMethodDescriptor resourceMethodDescriptor = statusResourceModel.findMethod(ResourceMethod.GET);
    final StatusCollectionResource resource = getMockResource(StatusCollectionResource.class);
    RestRequestBuilder builder =
        new RestRequestBuilder(new URI("/statuses/1")).setMethod("GET")
                                                      .addHeaderValue("Accept", "application/json")
                                                      .setHeader(RestConstants.HEADER_RESTLI_PROTOCOL_VERSION,
                                                                 AllProtocolVersions.LATEST_PROTOCOL_VERSION.toString());
    RestRequest request = builder.build();
    RoutingResult routingResult =
        new RoutingResult(new ResourceContextImpl(buildPathKeys("statusID", 1L), request, new RequestContext()),
                          resourceMethodDescriptor);
    expect(mockRegistry.getArgumentBuilder(resourceMethodDescriptor.getType())).andReturn(mockBuilder);
    expect(mockBuilder.extractRequestData(routingResult, request)).andReturn(requestData);
    mockFilterContext.setRequestData(requestData);
    final Exception exFromFilter = new RuntimeException("Exception from filter!");
    if (throwExceptionFromFirstFilter)
    {
      mockFilter.onRequest(mockFilterContext);
      expectLastCall().andThrow(exFromFilter);
      mockCallback.onError(eq(exFromFilter), anyObject(RequestExecutionReport.class));
    }
    else
    {
      expect(mockFilterContext.getRequestData()).andReturn(requestData).times(3);
      mockFilter.onRequest(mockFilterContext);
      expectLastCall().andAnswer(new IAnswer<Object>()
      {
        @Override
        public Object answer() throws Throwable
View Full Code Here


      restLiCallback.onError(e, createEmptyExecutionReport());
      return;
    }
    final RequestExecutionCallback<RestResponse> wrappedCallback = notifyInvokeAwares(method, callback);

    final FilterRequestContextInternal filterContext =
        new FilterRequestContextInternalImpl((ServerResourceContext) method.getContext(), method.getResourceMethod());
    final RestLiCallback<Object> restLiCallback =
        new RestLiCallback<Object>(request, method, _responseHandler, wrappedCallback, _responseFilters, filterContext);
    try
    {
View Full Code Here

TOP

Related Classes of com.linkedin.restli.internal.server.filter.FilterRequestContextInternal

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.