private static AtomicReference<NetworkEventReporter.InspectorRequest> hookAlmostRealRequestWillBeSent( final NetworkEventReporter mockEventReporter) { final AtomicReference<NetworkEventReporter.InspectorRequest> capturedRequest = new AtomicReference<>(null); Mockito.doAnswer( new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { Object[] args = invocation.getArguments(); NetworkEventReporter.InspectorRequest request = (NetworkEventReporter.InspectorRequest)args[0]; capturedRequest.set(request); // Access the body, causing the body helper to perform decompression... request.body(); return null; } }) .when(mockEventReporter) .requestWillBeSent( any(NetworkEventReporter.InspectorRequest.class)); return capturedRequest; }
private static AtomicReference<NetworkEventReporter.InspectorRequest> hookAlmostRealRequestWillBeSent( final NetworkEventReporter mockEventReporter) { final AtomicReference<NetworkEventReporter.InspectorRequest> capturedRequest = new AtomicReference<>(null); Mockito.doAnswer( new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { Object[] args = invocation.getArguments(); NetworkEventReporter.InspectorRequest request = (NetworkEventReporter.InspectorRequest)args[0]; capturedRequest.set(request); // Access the body, causing the body helper to perform decompression... request.body(); return null; } }) .when(mockEventReporter) .requestWillBeSent( any(NetworkEventReporter.InspectorRequest.class)); return capturedRequest; }
/** * @see StethoURLConnectionManager#preConnect */ public void preConnect( HttpURLConnection connection, @Nullable SimpleRequestEntity requestEntity) { throwIfConnection(); mConnection = connection; if (isStethoActive()) { mRequestBodyHelper = new RequestBodyHelper(mStethoHook, getStethoRequestId()); mInspectorRequest = new URLConnectionInspectorRequest( getStethoRequestId(), mFriendlyName, connection, requestEntity, mRequestBodyHelper); mStethoHook.requestWillBeSent(mInspectorRequest); } }
OkHttpInspectorRequest inspectorRequest = new OkHttpInspectorRequest(requestId, request, requestBodyHelper); mEventReporter.requestWillBeSent(inspectorRequest);
.requestWillBeSent(any(NetworkEventReporter.InspectorRequest.class)); inOrder.verify(mMockEventReporter) .dataSent(
.requestWillBeSent(any(NetworkEventReporter.InspectorRequest.class)); inOrder.verify(mMockEventReporter) .dataSent(
OkHttpInspectorRequest inspectorRequest = new OkHttpInspectorRequest(requestId, request, requestBodyHelper); mEventReporter.requestWillBeSent(inspectorRequest);
OkHttpInspectorRequest inspectorRequest = new OkHttpInspectorRequest(requestId, request, requestBodyHelper); mEventReporter.requestWillBeSent(inspectorRequest);