Search in sources :

Example 1 with TestCaseRecorderImpl

use of org.webpieces.microsvc.server.impl.TestCaseRecorderImpl in project webpieces by deanhiller.

the class RecordingFilter method writeOutTestCase.

private Action writeOutTestCase(Action resp) {
    TestCaseRecorderImpl recorder = (TestCaseRecorderImpl) Context.get(TestCaseRecorder.RECORDER_KEY);
    recorder.spitOutTestCase();
    return resp;
}
Also used : TestCaseRecorderImpl(org.webpieces.microsvc.server.impl.TestCaseRecorderImpl)

Example 2 with TestCaseRecorderImpl

use of org.webpieces.microsvc.server.impl.TestCaseRecorderImpl in project webpieces by deanhiller.

the class RecordingFilter method filter.

@Override
public XFuture<Action> filter(MethodMeta meta, Service<MethodMeta, Action> nextFilter) {
    RequestContext context = Current.getContext();
    List<RouterHeader> routerHeaders = context.getRequest().getHeaders().get(MicroSvcHeader.RECORDING.getHeaderName());
    if (routerHeaders == null)
        return nextFilter.invoke(meta);
    Map<String, Object> fullRequestContext = Context.copyContext();
    // let the recording begin...
    Context.put(TestCaseRecorder.RECORDER_KEY, new TestCaseRecorderImpl(Current.getContext().getRequest().originalRequest, meta, fullRequestContext));
    return nextFilter.invoke(meta).thenApply((resp) -> writeOutTestCase(resp));
}
Also used : TestCaseRecorderImpl(org.webpieces.microsvc.server.impl.TestCaseRecorderImpl) RequestContext(org.webpieces.ctx.api.RequestContext) RouterHeader(org.webpieces.ctx.api.RouterHeader)

Aggregations

TestCaseRecorderImpl (org.webpieces.microsvc.server.impl.TestCaseRecorderImpl)2 RequestContext (org.webpieces.ctx.api.RequestContext)1 RouterHeader (org.webpieces.ctx.api.RouterHeader)1