Search in sources :

Example 1 with RestLiRouter

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

the class TestRestLiRouting method testNKeyAssociationRoutingBasicNonBatch.

@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "nKeyAssociationRouting")
public void testNKeyAssociationRoutingBasicNonBatch(String uri, ProtocolVersion version, String httpMethod, ResourceMethod method, String methodName, String[] expectedPathKeys) throws Exception {
    Map<String, ResourceModel> pathRootResourceMap = buildResourceModels(CombinedResources.CombinedNKeyAssociationResource.class);
    _router = new RestLiRouter(pathRootResourceMap, new RestLiConfig());
    checkResult(uri, version, httpMethod, method, CombinedResources.CombinedNKeyAssociationResource.class, methodName, false, expectedPathKeys);
}
Also used : RestLiRouter(com.linkedin.restli.internal.server.RestLiRouter) CombinedResources(com.linkedin.restli.server.combined.CombinedResources) ResourceModel(com.linkedin.restli.internal.server.model.ResourceModel) RestLiConfig(com.linkedin.restli.server.RestLiConfig) Test(org.testng.annotations.Test)

Example 2 with RestLiRouter

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

the class TestRestLiRouting method testDefaultPathKeyUniqueness.

@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "uniqueness")
public void testDefaultPathKeyUniqueness(ProtocolVersion version, String uri) throws Exception {
    Map<String, ResourceModel> pathRootResourceMap = buildResourceModels(CombinedResources.CombinedCollectionWithSubresources.class, CombinedResources.SubCollectionResource.class);
    _router = new RestLiRouter(pathRootResourceMap, new RestLiConfig());
    RestRequest request;
    // #1 simple GET
    request = createRequest(uri, "GET", version);
    ServerResourceContext context = new ResourceContextImpl(new PathKeysImpl(), request, new RequestContext());
    ResourceMethodDescriptor method = _router.process(context);
    assertNotNull(method);
    PathKeys keys = context.getPathKeys();
    assertEquals(keys.getAsString("testId"), "foo");
    assertEquals(keys.getAsString("subId"), "bar");
}
Also used : CombinedResources(com.linkedin.restli.server.combined.CombinedResources) PathKeysImpl(com.linkedin.restli.internal.server.PathKeysImpl) ResourceMethodDescriptor(com.linkedin.restli.internal.server.model.ResourceMethodDescriptor) PathKeys(com.linkedin.restli.server.PathKeys) RestLiRouter(com.linkedin.restli.internal.server.RestLiRouter) RestRequest(com.linkedin.r2.message.rest.RestRequest) ServerResourceContext(com.linkedin.restli.internal.server.ServerResourceContext) ResourceModel(com.linkedin.restli.internal.server.model.ResourceModel) RequestContext(com.linkedin.r2.message.RequestContext) RestLiConfig(com.linkedin.restli.server.RestLiConfig) ResourceContextImpl(com.linkedin.restli.internal.server.ResourceContextImpl) Test(org.testng.annotations.Test)

Example 3 with RestLiRouter

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

the class TestRestLiRouting method testRoutingDetailsSimpleGet.

@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "routingDetailsSimple")
public void testRoutingDetailsSimpleGet(ProtocolVersion version, String uri) throws Exception {
    Map<String, ResourceModel> pathRootResourceMap = buildResourceModels(TrendingResource.class);
    _router = new RestLiRouter(pathRootResourceMap, new RestLiConfig());
    RestRequest request = createRequest(uri, "GET", version);
    ServerResourceContext context = new ResourceContextImpl(new PathKeysImpl(), request, new RequestContext());
    ResourceMethodDescriptor resourceMethodDescriptor = _router.process(context);
    assertNotNull(resourceMethodDescriptor);
    assertEquals(resourceMethodDescriptor.getType(), ResourceMethod.GET);
    assertNull(resourceMethodDescriptor.getActionName());
    assertNull(resourceMethodDescriptor.getFinderName());
    assertEquals(resourceMethodDescriptor.getMethod().getDeclaringClass(), TrendingResource.class);
    assertEquals(resourceMethodDescriptor.getMethod().getName(), "get");
    assertEquals(resourceMethodDescriptor.getMethod().getParameterTypes(), new Class<?>[] {});
    assertEquals(resourceMethodDescriptor.getResourceModel().getName(), "trending");
    PathKeys keys = context.getPathKeys();
    assertNull(keys.getBatchIds());
}
Also used : PathKeys(com.linkedin.restli.server.PathKeys) RestLiRouter(com.linkedin.restli.internal.server.RestLiRouter) RestRequest(com.linkedin.r2.message.rest.RestRequest) ServerResourceContext(com.linkedin.restli.internal.server.ServerResourceContext) PathKeysImpl(com.linkedin.restli.internal.server.PathKeysImpl) ResourceMethodDescriptor(com.linkedin.restli.internal.server.model.ResourceMethodDescriptor) ResourceModel(com.linkedin.restli.internal.server.model.ResourceModel) RequestContext(com.linkedin.r2.message.RequestContext) RestLiConfig(com.linkedin.restli.server.RestLiConfig) ResourceContextImpl(com.linkedin.restli.internal.server.ResourceContextImpl) Test(org.testng.annotations.Test)

Example 4 with RestLiRouter

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

the class TestRestLiRouting method testRoutingComplexKeyBatch.

@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "routingComplexKeyBatch")
public void testRoutingComplexKeyBatch(String uri, ProtocolVersion version, String httpMethod, String restliMethod, ResourceMethod method, String methodName, Set<ComplexResourceKey<TwitterTestDataModels.DiscoveredItemKey, TwitterTestDataModels.DiscoveredItemKeyParams>> compoundKeys) throws Exception {
    Map<String, ResourceModel> pathRootResourceMap = buildResourceModels(DiscoveredItemsResource.class);
    _router = new RestLiRouter(pathRootResourceMap, new RestLiConfig());
    checkResult(uri, version, httpMethod, restliMethod, method, DiscoveredItemsResource.class, methodName, true);
    checkBatchKeys(uri, version, httpMethod, compoundKeys);
}
Also used : RestLiRouter(com.linkedin.restli.internal.server.RestLiRouter) ResourceModel(com.linkedin.restli.internal.server.model.ResourceModel) RestLiConfig(com.linkedin.restli.server.RestLiConfig) Test(org.testng.annotations.Test)

Example 5 with RestLiRouter

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

the class TestRestLiRouting method testRoutingCollectionBatch.

@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "routingCollectionBatch")
public void testRoutingCollectionBatch(String uri, ProtocolVersion version, String httpMethod, String restliMethod, ResourceMethod method, String methodName, Set<Long> keys) throws Exception {
    Map<String, ResourceModel> pathRootResourceMap = buildResourceModels(StatusCollectionResource.class);
    _router = new RestLiRouter(pathRootResourceMap, new RestLiConfig());
    checkResult(uri, version, httpMethod, restliMethod, method, StatusCollectionResource.class, methodName, true);
    checkBatchKeys(uri, version, httpMethod, keys);
}
Also used : RestLiRouter(com.linkedin.restli.internal.server.RestLiRouter) ResourceModel(com.linkedin.restli.internal.server.model.ResourceModel) RestLiConfig(com.linkedin.restli.server.RestLiConfig) Test(org.testng.annotations.Test)

Aggregations

RestLiRouter (com.linkedin.restli.internal.server.RestLiRouter)32 ResourceModel (com.linkedin.restli.internal.server.model.ResourceModel)32 RestLiConfig (com.linkedin.restli.server.RestLiConfig)32 Test (org.testng.annotations.Test)32 RequestContext (com.linkedin.r2.message.RequestContext)14 RestRequest (com.linkedin.r2.message.rest.RestRequest)14 PathKeysImpl (com.linkedin.restli.internal.server.PathKeysImpl)14 ResourceContextImpl (com.linkedin.restli.internal.server.ResourceContextImpl)14 ServerResourceContext (com.linkedin.restli.internal.server.ServerResourceContext)14 ResourceMethodDescriptor (com.linkedin.restli.internal.server.model.ResourceMethodDescriptor)14 PathKeys (com.linkedin.restli.server.PathKeys)10 CombinedResources (com.linkedin.restli.server.combined.CombinedResources)4 RestRequestBuilder (com.linkedin.r2.message.rest.RestRequestBuilder)1 CompoundKey (com.linkedin.restli.common.CompoundKey)1 URI (java.net.URI)1 HashSet (java.util.HashSet)1