@Test public <R extends RequestBuilder & RequestFilterContext> void process_ShouldFilterThenSerializeThenIntercept() { @SuppressWarnings("unchecked") R request = (R) mock(RequestBuilder.class, withSettings().extraInterfaces(RequestFilterContext.class)); SerializedRequestDelegate interceptorContext = mock(SerializedRequestDelegate.class); when(serializationEngine.serializeRequest(request)).thenReturn(interceptorContext); processor.process(request); InOrder inOrder = inOrder(serializationEngine, filterEngine, interceptorEngine); inOrder.verify(filterEngine).filterRequest(request); inOrder.verify(serializationEngine).serializeRequest(request); inOrder.verify(interceptorEngine).interceptRequest(interceptorContext); }
public <R extends RequestBuilder & RequestFilterContext> SerializedRequest process(R request) { filterEngine.filterRequest(request); SerializedRequestDelegate serializedRequest; Object payload = request.getPayload(); if (payload instanceof Payload) { serializedRequest = new SerializedRequestDelegate(request, (Payload) payload); } else if (payload instanceof FormData) { final Payload serializedPayload = formDataSerializer.serialize((FormData) payload); final String mediaType = formDataSerializer.mediaType(); if (mediaType == null) { request.removeHeader("Content-Type"); } else { request.addHeader(new ContentTypeHeader(mediaType)); } serializedRequest = new SerializedRequestDelegate(request, serializedPayload); } else { serializedRequest = serializationEngine.serializeRequest(request); } interceptorEngine.interceptRequest(serializedRequest); return serializedRequest; }
RequestProcessor { public <R extends RequestBuilder & RequestFilterContext> SerializedRequest process(R request) { filterEngine.filterRequest(request); SerializedRequestDelegate serializedRequest; Object payload = request.getPayload(); if (payload instanceof Payload) { serializedRequest = new SerializedRequestDelegate(request, (Payload) payload); } else if (payload instanceof FormData) { final Payload serializedPayload = formDataSerializer.serialize((FormData) payload); final String mediaType = formDataSerializer.mediaType(); if (mediaType == null) { request.removeHeader("Content-Type"); } else { request.addHeader(new ContentTypeHeader(mediaType)); } serializedRequest = new SerializedRequestDelegate(request, serializedPayload); } else { serializedRequest = serializationEngine.serializeRequest(request); } interceptorEngine.interceptRequest(serializedRequest); return serializedRequest; } }
RequestProcessor { public <R extends RequestBuilder & RequestFilterContext> SerializedRequest process(R request) { filterEngine.filterRequest(request); SerializedRequestDelegate serializedRequest; Object payload = request.getPayload(); if (payload instanceof Payload) { serializedRequest = new SerializedRequestDelegate(request, (Payload) payload); } else if (payload instanceof FormData) { final Payload serializedPayload = formDataSerializer.serialize((FormData) payload); final String mediaType = formDataSerializer.mediaType(); if (mediaType == null) { request.removeHeader("Content-Type"); } else { request.addHeader(new ContentTypeHeader(mediaType)); } serializedRequest = new SerializedRequestDelegate(request, serializedPayload); } else { serializedRequest = serializationEngine.serializeRequest(request); } interceptorEngine.interceptRequest(serializedRequest); return serializedRequest; } RequestProcessor(SerializationEngine serializationEngine, FilterEngine filterEngine,
                            InterceptorEngine interceptorEngine, FormDataSerializer formDataSerializer); }
RequestProcessor { public <R extends RequestBuilder & RequestFilterContext> SerializedRequest process(R request) { filterEngine.filterRequest(request); SerializedRequestDelegate serializedRequest; Object payload = request.getPayload(); if (payload instanceof Payload) { serializedRequest = new SerializedRequestDelegate(request, (Payload) payload); } else if (payload instanceof FormData) { final Payload serializedPayload = formDataSerializer.serialize((FormData) payload); final String mediaType = formDataSerializer.mediaType(); if (mediaType == null) { request.removeHeader("Content-Type"); } else { request.addHeader(new ContentTypeHeader(mediaType)); } serializedRequest = new SerializedRequestDelegate(request, serializedPayload); } else { serializedRequest = serializationEngine.serializeRequest(request); } interceptorEngine.interceptRequest(serializedRequest); return serializedRequest; } RequestProcessor(SerializationEngine serializationEngine, FilterEngine filterEngine,
                            InterceptorEngine interceptorEngine, FormDataSerializer formDataSerializer); SerializedRequest process(R request); }
RequestProcessor { public <R extends RequestBuilder & RequestFilterContext> SerializedRequest process(R request) { filterEngine.filterRequest(request); SerializedRequestDelegate serializedRequest; Object payload = request.getPayload(); if (payload instanceof Payload) { serializedRequest = new SerializedRequestDelegate(request, (Payload) payload); } else if (payload instanceof FormData) { final Payload serializedPayload = formDataSerializer.serialize((FormData) payload); final String mediaType = formDataSerializer.mediaType(); if (mediaType == null) { request.removeHeader("Content-Type"); } else { request.addHeader(new ContentTypeHeader(mediaType)); } serializedRequest = new SerializedRequestDelegate(request, serializedPayload); } else { serializedRequest = serializationEngine.serializeRequest(request); } interceptorEngine.interceptRequest(serializedRequest); return serializedRequest; } RequestProcessor(SerializationEngine serializationEngine, FilterEngine filterEngine,
                            InterceptorEngine interceptorEngine, FormDataSerializer formDataSerializer); SerializedRequest process(R request);  }