Search in sources :

Example 46 with ServerResourceContext

use of com.linkedin.restli.internal.server.ServerResourceContext in project rest.li by linkedin.

the class RestLiArgumentBuilderTestHelper method getMockResourceContext.

public static ServerResourceContext getMockResourceContext(MutablePathKeys pathKeys, boolean returnStructuredParameter, boolean attachmentReaderGetExpected) {
    ServerResourceContext context = createMock(ServerResourceContext.class);
    if (pathKeys != null) {
        expect(context.getPathKeys()).andReturn(pathKeys);
    }
    if (returnStructuredParameter) {
        expect(context.getStructuredParameter("")).andReturn(null);
    }
    if (attachmentReaderGetExpected) {
        expect(context.getRequestAttachmentReader()).andReturn(null);
    }
    replay(context);
    return context;
}
Also used : ServerResourceContext(com.linkedin.restli.internal.server.ServerResourceContext)

Example 47 with ServerResourceContext

use of com.linkedin.restli.internal.server.ServerResourceContext in project rest.li by linkedin.

the class RestLiArgumentBuilderTestHelper method getMockResourceContext.

static ServerResourceContext getMockResourceContext(Set<Object> batchKeys, boolean attachmentReaderGetExpected, boolean hasAlternateKeyParam) {
    ServerResourceContext context = createMock(ServerResourceContext.class);
    if (batchKeys != null) {
        PathKeysImpl pathKeys = new PathKeysImpl();
        if (batchKeys != null) {
            pathKeys.setBatchKeys(batchKeys);
        }
        expect(context.getPathKeys()).andReturn(pathKeys);
    }
    if (attachmentReaderGetExpected) {
        expect(context.getRequestAttachmentReader()).andReturn(null);
    }
    expect(context.getParameter(RestConstants.ALT_KEY_PARAM)).andReturn(hasAlternateKeyParam ? "" : null).anyTimes();
    replay(context);
    return context;
}
Also used : ServerResourceContext(com.linkedin.restli.internal.server.ServerResourceContext) PathKeysImpl(com.linkedin.restli.internal.server.PathKeysImpl)

Example 48 with ServerResourceContext

use of com.linkedin.restli.internal.server.ServerResourceContext in project rest.li by linkedin.

the class RestLiArgumentBuilderTestHelper method getMockResourceContext.

public static ServerResourceContext getMockResourceContext(String keyName, Object keyValue, Set<Object> batchKeys, Map<String, String> headers, boolean attachmentReaderGetExpected) {
    ServerResourceContext context = createMock(ServerResourceContext.class);
    if (keyName != null || batchKeys != null) {
        PathKeysImpl pathKeys = new PathKeysImpl();
        if (keyName != null) {
            pathKeys.append(keyName, keyValue);
        }
        if (batchKeys != null) {
            pathKeys.setBatchKeys(batchKeys);
        }
        expect(context.getPathKeys()).andReturn(pathKeys);
    }
    if (headers != null) {
        expect(context.getRequestHeaders()).andReturn(headers);
    }
    if (attachmentReaderGetExpected) {
        expect(context.getRequestAttachmentReader()).andReturn(null);
    }
    replay(context);
    return context;
}
Also used : ServerResourceContext(com.linkedin.restli.internal.server.ServerResourceContext) PathKeysImpl(com.linkedin.restli.internal.server.PathKeysImpl)

Example 49 with ServerResourceContext

use of com.linkedin.restli.internal.server.ServerResourceContext in project rest.li by linkedin.

the class RestLiArgumentBuilderTestHelper method getMockResourceContext.

public static ServerResourceContext getMockResourceContext(String parameterKey, List<String> parameterValues, boolean attachmentReaderGetExpected) {
    ServerResourceContext context = createMock(ServerResourceContext.class);
    expect(context.getParameter(parameterKey)).andReturn(parameterValues.get(0));
    expect(context.getParameterValues(parameterKey)).andReturn(parameterValues);
    if (attachmentReaderGetExpected) {
        expect(context.getRequestAttachmentReader()).andReturn(null);
    }
    replay(context);
    return context;
}
Also used : ServerResourceContext(com.linkedin.restli.internal.server.ServerResourceContext)

Example 50 with ServerResourceContext

use of com.linkedin.restli.internal.server.ServerResourceContext in project rest.li by linkedin.

the class TestBatchUpdateResponseBuilder method getMockResourceContext.

private static ResourceContext getMockResourceContext(ProtocolVersion protocolVersion, String altKeyName) {
    ServerResourceContext mockContext = EasyMock.createMock(ServerResourceContext.class);
    EasyMock.expect(mockContext.getBatchKeyErrors()).andReturn(Collections.<Object, RestLiServiceException>emptyMap()).once();
    EasyMock.expect(mockContext.getRestliProtocolVersion()).andReturn(protocolVersion).once();
    EasyMock.expect(mockContext.hasParameter(RestConstants.ALT_KEY_PARAM)).andReturn(altKeyName != null).anyTimes();
    if (altKeyName != null) {
        EasyMock.expect(mockContext.getParameter(RestConstants.ALT_KEY_PARAM)).andReturn(altKeyName).atLeastOnce();
    }
    EasyMock.replay(mockContext);
    return mockContext;
}
Also used : RestLiServiceException(com.linkedin.restli.server.RestLiServiceException) ServerResourceContext(com.linkedin.restli.internal.server.ServerResourceContext)

Aggregations

ServerResourceContext (com.linkedin.restli.internal.server.ServerResourceContext)55 Test (org.testng.annotations.Test)28 RoutingResult (com.linkedin.restli.internal.server.RoutingResult)18 Parameter (com.linkedin.restli.internal.server.model.Parameter)15 ResourceContextImpl (com.linkedin.restli.internal.server.ResourceContextImpl)14 DataMap (com.linkedin.data.DataMap)13 RestLiServiceException (com.linkedin.restli.server.RestLiServiceException)12 HashMap (java.util.HashMap)11 RequestContext (com.linkedin.r2.message.RequestContext)10 PathKeysImpl (com.linkedin.restli.internal.server.PathKeysImpl)10 ResourceMethodDescriptor (com.linkedin.restli.internal.server.model.ResourceMethodDescriptor)9 RestRequest (com.linkedin.r2.message.rest.RestRequest)8 RestLiAttachmentReader (com.linkedin.restli.common.attachments.RestLiAttachmentReader)7 URI (java.net.URI)7 ByteString (com.linkedin.data.ByteString)6 RestRequestBuilder (com.linkedin.r2.message.rest.RestRequestBuilder)6 RestResponse (com.linkedin.r2.message.rest.RestResponse)6 RoutingException (com.linkedin.restli.server.RoutingException)6 MaskTree (com.linkedin.data.transform.filter.request.MaskTree)5 ResourceModel (com.linkedin.restli.internal.server.model.ResourceModel)5