Search in sources :

Example 16 with PathKeysImpl

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

the class TestRestLiResponseHandler method testGetRequestCookies.

@Test
public void testGetRequestCookies() throws URISyntaxException, RestLiSyntaxException {
    List<HttpCookie> cookies = Arrays.asList(new HttpCookie("cook1", "value1"), new HttpCookie("cook2", "value2"));
    RestRequest request = new RestRequestBuilder(new URI("http://www.abc.org/")).setMethod("DONT_CARE").setHeaders(new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER)).setCookies(CookieUtil.encodeCookies(cookies)).build();
    ServerResourceContext resourceContext = new ResourceContextImpl(new PathKeysImpl(), request, new RequestContext());
    Assert.assertEquals(resourceContext.getRequestCookies(), cookies);
}
Also used : RestRequest(com.linkedin.r2.message.rest.RestRequest) ServerResourceContext(com.linkedin.restli.internal.server.ServerResourceContext) PathKeysImpl(com.linkedin.restli.internal.server.PathKeysImpl) RestRequestBuilder(com.linkedin.r2.message.rest.RestRequestBuilder) ByteString(com.linkedin.data.ByteString) RequestContext(com.linkedin.r2.message.RequestContext) HttpCookie(java.net.HttpCookie) URI(java.net.URI) ResourceContextImpl(com.linkedin.restli.internal.server.ResourceContextImpl) Test(org.testng.annotations.Test)

Example 17 with PathKeysImpl

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

the class RestLiArgumentBuilderTestHelper method getMockResourceContext.

public static ResourceContext getMockResourceContext() {
    ResourceContext context = createMock(ResourceContext.class);
    PathKeysImpl pathKeys = new PathKeysImpl();
    expect(context.getPathKeys()).andReturn(pathKeys);
    replay(context);
    return context;
}
Also used : ResourceContext(com.linkedin.restli.server.ResourceContext) ServerResourceContext(com.linkedin.restli.internal.server.ServerResourceContext) PathKeysImpl(com.linkedin.restli.internal.server.PathKeysImpl)

Example 18 with PathKeysImpl

use of com.linkedin.restli.internal.server.PathKeysImpl 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 19 with PathKeysImpl

use of com.linkedin.restli.internal.server.PathKeysImpl 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)

Aggregations

PathKeysImpl (com.linkedin.restli.internal.server.PathKeysImpl)19 ServerResourceContext (com.linkedin.restli.internal.server.ServerResourceContext)14 RequestContext (com.linkedin.r2.message.RequestContext)12 ResourceContextImpl (com.linkedin.restli.internal.server.ResourceContextImpl)11 Test (org.testng.annotations.Test)9 ByteString (com.linkedin.data.ByteString)7 URI (java.net.URI)7 DataMap (com.linkedin.data.DataMap)6 HashMap (java.util.HashMap)6 MaskTree (com.linkedin.data.transform.filter.request.MaskTree)5 RoutingResult (com.linkedin.restli.internal.server.RoutingResult)5 ResourceMethod (com.linkedin.restli.common.ResourceMethod)4 ResourceMethodDescriptor (com.linkedin.restli.internal.server.model.ResourceMethodDescriptor)4 ResourceModel (com.linkedin.restli.internal.server.model.ResourceModel)4 RestLiTestHelper.buildResourceModel (com.linkedin.restli.server.test.RestLiTestHelper.buildResourceModel)4 RestRequest (com.linkedin.r2.message.rest.RestRequest)3 MutablePathKeys (com.linkedin.restli.internal.server.MutablePathKeys)3 ResourceContext (com.linkedin.restli.server.ResourceContext)3 Method (java.lang.reflect.Method)3 BeforeTest (org.testng.annotations.BeforeTest)3