use of com.linkedin.restli.internal.server.methods.arguments.RestLiArgumentBuilder in project rest.li by linkedin.
the class TestRestLiMethodInvocation method checkAsyncInvocation.
@SuppressWarnings({ "unchecked", "rawtypes" })
private void checkAsyncInvocation(BaseResource resource, RestLiCallback callback, ResourceMethodDescriptor methodDescriptor, String httpMethod, ProtocolVersion version, String uri, String entityBody, MutablePathKeys pathkeys, boolean isDebugMode) throws Exception {
try {
RestRequestBuilder builder = new RestRequestBuilder(new URI(uri)).setMethod(httpMethod).addHeaderValue("Accept", "application/x-pson").setHeader(RestConstants.HEADER_RESTLI_PROTOCOL_VERSION, version.toString());
if (entityBody != null) {
builder.setEntity(entityBody.getBytes(Data.UTF_8_CHARSET));
}
RestRequest request = builder.build();
RoutingResult routingResult = new RoutingResult(new ResourceContextImpl(pathkeys, request, new RequestContext()), methodDescriptor);
RestLiArgumentBuilder argumentBuilder = _methodAdapterProvider.getArgumentBuilder(methodDescriptor.getType());
RestLiRequestData requestData = argumentBuilder.extractRequestData(routingResult, entityBody != null ? DataMapUtils.readMapWithExceptions(request) : null);
RestUtils.validateRequestHeadersAndUpdateResourceContext(request.getHeaders(), Collections.emptySet(), routingResult.getContext());
_invoker.invoke(requestData, routingResult, argumentBuilder, callback);
EasyMock.verify(resource);
EasyMock.verify(callback);
Assert.assertEquals((routingResult.getContext()).getResponseMimeType(), "application/x-pson");
} catch (RestLiSyntaxException e) {
throw new RoutingException("syntax exception", 400);
} finally {
EasyMock.reset(callback, resource);
callback.onSuccess(EasyMock.anyObject());
EasyMock.expectLastCall().once();
EasyMock.replay(callback);
}
}
use of com.linkedin.restli.internal.server.methods.arguments.RestLiArgumentBuilder in project rest.li by linkedin.
the class DefaultMethodAdapterProvider method buildAdapterRegistry.
private Map<ResourceMethod, RestLiArgumentBuilder> buildAdapterRegistry() {
Map<ResourceMethod, RestLiArgumentBuilder> result = new HashMap<>(ResourceMethod.values().length);
result.put(ResourceMethod.GET, new GetArgumentBuilder());
result.put(ResourceMethod.BATCH_GET, new BatchGetArgumentBuilder());
result.put(ResourceMethod.FINDER, new CollectionArgumentBuilder());
result.put(ResourceMethod.BATCH_FINDER, new CollectionArgumentBuilder());
result.put(ResourceMethod.CREATE, new CreateArgumentBuilder());
result.put(ResourceMethod.PARTIAL_UPDATE, new PatchArgumentBuilder());
result.put(ResourceMethod.UPDATE, new UpdateArgumentBuilder());
result.put(ResourceMethod.DELETE, new GetArgumentBuilder());
result.put(ResourceMethod.ACTION, new ActionArgumentBuilder());
result.put(ResourceMethod.BATCH_UPDATE, new BatchUpdateArgumentBuilder());
result.put(ResourceMethod.BATCH_PARTIAL_UPDATE, new BatchPatchArgumentBuilder());
result.put(ResourceMethod.BATCH_CREATE, new BatchCreateArgumentBuilder());
result.put(ResourceMethod.BATCH_DELETE, new BatchDeleteArgumentBuilder());
result.put(ResourceMethod.GET_ALL, new CollectionArgumentBuilder());
return Collections.unmodifiableMap(result);
}
Aggregations