Search in sources :

Example 31 with RestLiRouter

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

the class TestRestLiRouting method testRoutingErrors.

@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "routingErrors")
public void testRoutingErrors(String uri, ProtocolVersion version, String httpMethod, HttpStatus status) throws Exception {
    Map<String, ResourceModel> pathRootResourceMap = buildResourceModels(CombinedResources.CombinedNKeyAssociationResource.class, DiscoveredItemsResource.class, FollowsAssociativeResource.class, LocationResource.class, RepliesCollectionResource.class, StatusCollectionResource.class, CustomStatusCollectionResource.class, TrendRegionsCollectionResource.class, TrendingResource.class, TwitterAccountsResource.class);
    _router = new RestLiRouter(pathRootResourceMap, new RestLiConfig());
    expectRoutingExceptionWithStatus(uri, version, httpMethod, null, status);
}
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 32 with RestLiRouter

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

the class TestRestLiRouting method testActionRootRouting.

@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "actionRootRouting")
public void testActionRootRouting(ProtocolVersion version, String uri, String actionName) throws Exception {
    Map<String, ResourceModel> pathRootResourceMap = buildResourceModels(TwitterAccountsResource.class);
    _router = new RestLiRouter(pathRootResourceMap, new RestLiConfig());
    RestRequest request = createRequest(uri, "POST", version);
    ServerResourceContext context = new ResourceContextImpl(new PathKeysImpl(), request, new RequestContext());
    ResourceMethodDescriptor method = _router.process(context);
    assertNotNull(method);
    assertEquals(method.getActionName(), actionName);
    assertEquals(method.getType(), ResourceMethod.ACTION);
}
Also used : 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)

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