@Test public void onError() { final SystemSchema schema = newSchema(); newConnection( createConnector( schema ) ); Replicant.context().request( schema.getId(), ValueUtil.randomString(), () -> { final replicant.Request r = Replicant.context().currentRequest( schema.getId() ); final RequestCallback chainedCallback = mock( RequestCallback.class ); final Request request = mock( Request.class ); final Response response = mock( Response.class ); when( response.getStatusCode() ).thenReturn( 400 ); final TestSpyEventHandler handler = registerTestSpyEventHandler(); final Throwable exception = new Throwable(); new ReplicantRequestCallback( r, chainedCallback ) .onError( request, exception ); handler.assertEventCount( 1 ); handler.assertNextEvent( RequestCompletedEvent.class, e -> { assertEquals( e.getRequestId(), r.getRequestId() ); assertFalse( e.isNormalCompletion() ); } ); verify( chainedCallback ).onError( eq( request ), eq( exception ) ); } ); }
@Override public void onError( final Request request, final Throwable exception ) { _replicantRequest.onFailure( () -> _callback.onError( request, exception ) ); }
ReplicantRequestCallback implements RequestCallback { @Override public void onError( final Request request, final Throwable exception ) { _replicantRequest.onFailure( () -> _callback.onError( request, exception ) ); } }
ReplicantRequestCallback implements RequestCallback { @Override public void onError( final Request request, final Throwable exception ) { _replicantRequest.onFailure( () -> _callback.onError( request, exception ) ); } ReplicantRequestCallback( @Nonnull final replicant.Request replicantRequest, @Nonnull final RequestCallback callback ); }
ReplicantRequestCallback implements RequestCallback { @Override public void onError( final Request request, final Throwable exception ) { _replicantRequest.onFailure( () -> _callback.onError( request, exception ) ); } ReplicantRequestCallback( @Nonnull final replicant.Request replicantRequest, @Nonnull final RequestCallback callback ); @Override void onResponseReceived( final Request request, final Response response ); @Override void onError( final Request request, final Throwable exception ); }
ReplicantRequestCallback implements RequestCallback { @Override public void onError( final Request request, final Throwable exception ) { _replicantRequest.onFailure( () -> _callback.onError( request, exception ) ); } ReplicantRequestCallback( @Nonnull final replicant.Request replicantRequest, @Nonnull final RequestCallback callback ); @Override void onResponseReceived( final Request request, final Response response ); @Override void onError( final Request request, final Throwable exception );  }