use of com.linkedin.restli.internal.server.model.ResourceModel in project rest.li by linkedin.
the class TestRestLiResourceModels method testBatchFinderWithMetadata.
@Test
public void testBatchFinderWithMetadata() {
ResourceModel resourceModel = buildResourceModel(CombinedResources.CollectionResourceWithBatchFinder.class);
ResourceMethodDescriptor batchFinderSchema = resourceModel.getResourceMethodDescriptors().get(0);
Assert.assertEquals(batchFinderSchema.getBatchFinderName(), "testBatchFinder");
Assert.assertEquals(batchFinderSchema.getCollectionCustomMetadataType(), CombinedTestDataModels.FooMetaData.class);
}
use of com.linkedin.restli.internal.server.model.ResourceModel 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);
}
use of com.linkedin.restli.internal.server.model.ResourceModel 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");
}
use of com.linkedin.restli.internal.server.model.ResourceModel 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());
}
use of com.linkedin.restli.internal.server.model.ResourceModel 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);
}
Aggregations