use of com.lonepulse.robozombie.proxy.InvocationContext in project RoboZombie by sahan.
the class RequestProcessorChain method onInitiate.
/**
* <p>Accepts the {@link InvocationContext} given to {@link #run(Object...)}} the {@link RequestProcessorChain}
* and translates the request metadata to a concrete instance of {@link HttpRequestBase}. The
* {@link HttpRequestBase}, together with the {@link InvocationContext} is then given to the root link
* which runs the {@link UriProcessor} and returns the resulting {@link HttpRequestBase}.</p>
*
* <p>See {@link AbstractRequestProcessor}.</p>
*
* {@inheritDoc}
*/
@Override
protected HttpRequestBase onInitiate(ProcessorChainLink<HttpRequestBase, RequestProcessorException> root, Object... args) {
InvocationContext context = assertAssignable(assertNotEmpty(args)[0], InvocationContext.class);
HttpRequestBase request = RequestUtils.translateRequestMethod(context);
//allow any exceptions to elevate to a chain-wide failure
return root.getProcessor().run(context, request);
}
use of com.lonepulse.robozombie.proxy.InvocationContext in project RoboZombie by sahan.
the class InterceptorEndpointTest method testParamInterceptor.
/**
* <p>Test for {@link Interceptor}s passed as a request parameters.</p>
*
* @since 1.3.0
*/
@Test
public final void testParamInterceptor() {
Robolectric.getFakeHttpLayer().interceptHttpRequests(false);
String subpath = "/param";
stubFor(get(urlEqualTo(subpath)).willReturn(aResponse().withStatus(200)));
final String value = "param";
interceptorEndpoint.paramInterceptor(new Interceptor() {
public void intercept(InvocationContext context, HttpRequestBase request) {
request.addHeader("X-Header", value);
}
});
verify(getRequestedFor(urlEqualTo(subpath)).withHeader("X-Header", equalTo("endpoint")).withHeader("X-Header", equalTo("request")).withHeader("X-Header", equalTo(value)).withHeader("Accept-Charset", equalTo("utf-8")));
}
Aggregations