Package com.linkedin.restli.server

Examples of com.linkedin.restli.server.ResourceContext


  public void testBuilder(Object results,
                          ProtocolVersion protocolVersion,
                          Map<String, UpdateStatus> expectedResults,
                          Map<String, ErrorResponse> expectedErrors)
  {
    ResourceContext mockContext = getMockResourceContext(protocolVersion);
    ResourceMethodDescriptor mockDescriptor = getMockResourceMethodDescriptor();
    RoutingResult routingResult = new RoutingResult(mockContext, mockDescriptor);

    Map<String, String> headers = getHeaders();
View Full Code Here


        Parameter.ParamType.BATCH,
        false,
        new AnnotationSet(new Annotation[]{}));
    ResourceMethodDescriptor descriptor = RestLiArgumentBuilderTestHelper.getMockResourceMethodDescriptor(model, param);
    Set<Object> batchKeys = new HashSet<Object>(Arrays.asList(keys));
    ResourceContext context = RestLiArgumentBuilderTestHelper.getMockResourceContext(null, null, batchKeys);
    RoutingResult routingResult = RestLiArgumentBuilderTestHelper.getMockRoutingResult(descriptor, 2, context, 2);

    RestLiArgumentBuilder argumentBuilder = new BatchUpdateArgumentBuilder();
    RestLiRequestData requestData = argumentBuilder.extractRequestData(routingResult, request);
    Object[] args = argumentBuilder.buildArguments(requestData, routingResult);
View Full Code Here

      Parameter.ParamType.BATCH,
      false,
      new AnnotationSet(new Annotation[]{}));
    ResourceMethodDescriptor descriptor = RestLiArgumentBuilderTestHelper.getMockResourceMethodDescriptor(null, param);
    Set<Object> batchKeys = new HashSet<Object>(Arrays.asList(keys));
    ResourceContext context = RestLiArgumentBuilderTestHelper.getMockResourceContext(null, null, batchKeys);
    RoutingResult routingResult = RestLiArgumentBuilderTestHelper.getMockRoutingResult(descriptor, 1, context, 2);

    RestLiArgumentBuilder argumentBuilder = new BatchPatchArgumentBuilder();
    RestLiRequestData requestData = argumentBuilder.extractRequestData(routingResult, request);
    Object[] args = argumentBuilder.buildArguments(requestData, routingResult);
View Full Code Here

public class ManualProjectionsResource extends CollectionResourceTemplate<Long, Greeting>
{
  @RestMethod.Get
  public Greeting get(Long key, @QueryParam("ignoreProjection") @Optional("false") boolean ignoreProjection)
  {
    ResourceContext context = getContext();

    Greeting greeting = new Greeting();

    context.setProjectionMode(ProjectionMode.MANUAL);
    MaskTree mask = context.getProjectionMask();
    if(mask != null && ignoreProjection == false)
    {
      if(mask.getOperations().get(Greeting.fields().message()) == MaskOperation.POSITIVE_MASK_OP)
      {
        greeting.setMessage("Projected message!");
View Full Code Here

  @Test(dataProvider = "testData")
  public void testBuilder(Object record, HttpStatus httpStatus)
  {
    Map<String, String> headers = getHeaders();
    ResourceContext mockContext = getMockResourceContext();
    ResourceMethodDescriptor mockDescriptor = getMockResourceMethodDescriptor();

    RoutingResult routingResult = new RoutingResult(mockContext, mockDescriptor);

    GetResponseBuilder getResponseBuilder = new GetResponseBuilder();
View Full Code Here

    return mockDescriptor;
  }

  private static ResourceContext getMockResourceContext()
  {
    ResourceContext mockContext = EasyMock.createMock(ResourceContext.class);
    EasyMock.expect(mockContext.getProjectionMode()).andReturn(ProjectionMode.AUTOMATIC).once();
    final DataMap projectionMask = new DataMap();
    projectionMask.put("stringField", 1);
    EasyMock.expect(mockContext.getProjectionMask()).andReturn(new MaskTree(projectionMask)).once();
    EasyMock.replay(mockContext);
    return mockContext;
  }
View Full Code Here

    return descriptor;
  }

  public static ResourceContext getMockResourceContext(String keyName, Object keyValue, Set<Object> batchKeys)
  {
    ResourceContext context = EasyMock.createMock(ResourceContext.class);
    if (keyName != null || batchKeys != null)
    {
      PathKeysImpl pathKeys = new PathKeysImpl();
      if (keyName != null)
      {
        pathKeys.append(keyName, keyValue);
      }
      if (batchKeys != null)
      {
        pathKeys.setBatchKeys(batchKeys);
      }
      EasyMock.expect(context.getPathKeys()).andReturn(pathKeys);
    }
    EasyMock.replay(context);
    return context;
  }
View Full Code Here

    return context;
  }

  public static ResourceContext getMockResourceContext(PathKeys pathKeys, boolean returnStructuredParameter)
  {
    ResourceContext context = EasyMock.createMock(ResourceContext.class);
    if (pathKeys != null)
    {
      EasyMock.expect(context.getPathKeys()).andReturn(pathKeys);
    }
    if (returnStructuredParameter)
    {
      EasyMock.expect(context.getStructuredParameter("")).andReturn(null);
    }
    EasyMock.replay(context);
    return context;
  }
View Full Code Here

    return context;
  }

  public static ResourceContext getMockResourceContext(Map<String, String> parameters)
  {
    ResourceContext context = EasyMock.createMock(ResourceContext.class);
    for (String key : parameters.keySet())
    {
      EasyMock.expect(context.getParameter(key)).andReturn(parameters.get(key));
    }
    EasyMock.replay(context);
    return context;
  }
View Full Code Here

    Capture<String> param3Capture = new Capture<String>();
    Capture<String> param4Capture = new Capture<String>();
    Capture<String> param5Capture = new Capture<String>();
    Capture<String> param6Capture = new Capture<String>();

    ResourceContext mockResourceContext = EasyMock.createMock(ResourceContext.class);
    PathKeys mockPathKeys = EasyMock.createMock(PathKeys.class);

    //easy mock for processing param1
    EasyMock.expect(mockPathKeys.get(EasyMock.capture(param1Capture))).andReturn(param1Value);
    EasyMock.expect(mockResourceContext.getPathKeys()).andReturn(mockPathKeys);
    //easy mock for processing param2
    EasyMock.expect(mockResourceContext.getParameter(EasyMock.capture(param2Capture))).andReturn(param2Value);
    //easy mock for processing param3
    EasyMock.expect(mockResourceContext.getStructuredParameter(EasyMock.capture(param3Capture))).andReturn(param3Value);
    //easy mock for processing param4
    EasyMock.expect(mockResourceContext.getStructuredParameter(EasyMock.capture(param4Capture))).andReturn(param4Value);
    //easy mock for processing param5
    EasyMock.expect(mockResourceContext.getStructuredParameter(EasyMock.capture(param5Capture))).andReturn(param5Value);
    //easy mock for processing param6
    EasyMock.expect(mockResourceContext.getStructuredParameter(EasyMock.capture(param6Capture))).andReturn(param6Value);
    EasyMock.replay(mockResourceContext, mockPathKeys);

    Object[] results = ArgumentBuilder.buildArgs(positionalArguments, parameters, mockResourceContext);

    EasyMock.verify(mockPathKeys, mockResourceContext);
View Full Code Here

TOP

Related Classes of com.linkedin.restli.server.ResourceContext

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.