@Test public void onSuccess_alreadyCompleted() { final Connection connection = createConnection(); final RequestEntry entry = connection.newRequest( "DoStuff", false ); final Request request = new Request( connection, entry ); final SafeProcedure onSuccess = () -> { }; request.onSuccess( ValueUtil.randomBoolean(), onSuccess ); final IllegalStateException exception = expectThrows( IllegalStateException.class, () -> request.onSuccess( ValueUtil.randomBoolean(), onSuccess ) ); assertEquals( exception.getMessage(), "Replicant-0073: Request.onSuccess invoked on completed request Request(DoStuff)[Id=1]." ); }
public final void onSuccess( final boolean messageComplete, @Nonnull final SafeProcedure onSuccess ) { if ( Replicant.shouldCheckApiInvariants() ) { apiInvariant( () -> !_entry.hasCompleted(), () -> "Replicant-0073: Request.onSuccess invoked on completed request " + _entry + "." ); } _entry.setNormalCompletion( true ); _entry.setExpectingResults( !messageComplete ); _connection.completeRequest( _entry, Objects.requireNonNull( onSuccess ) ); }
Request { public final void onSuccess( final boolean messageComplete, @Nonnull final SafeProcedure onSuccess ) { if ( Replicant.shouldCheckApiInvariants() ) { apiInvariant( () -> !_entry.hasCompleted(), () -> "Replicant-0073: Request.onSuccess invoked on completed request " + _entry + "." ); } _entry.setNormalCompletion( true ); _entry.setExpectingResults( !messageComplete ); _connection.completeRequest( _entry, Objects.requireNonNull( onSuccess ) ); } }
Request { public final void onSuccess( final boolean messageComplete, @Nonnull final SafeProcedure onSuccess ) { if ( Replicant.shouldCheckApiInvariants() ) { apiInvariant( () -> !_entry.hasCompleted(), () -> "Replicant-0073: Request.onSuccess invoked on completed request " + _entry + "." ); } _entry.setNormalCompletion( true ); _entry.setExpectingResults( !messageComplete ); _connection.completeRequest( _entry, Objects.requireNonNull( onSuccess ) ); } Request( @Nonnull final Connection connection, @Nonnull final RequestEntry entry ); }
Request { public final void onSuccess( final boolean messageComplete, @Nonnull final SafeProcedure onSuccess ) { if ( Replicant.shouldCheckApiInvariants() ) { apiInvariant( () -> !_entry.hasCompleted(), () -> "Replicant-0073: Request.onSuccess invoked on completed request " + _entry + "." ); } _entry.setNormalCompletion( true ); _entry.setExpectingResults( !messageComplete ); _connection.completeRequest( _entry, Objects.requireNonNull( onSuccess ) ); } Request( @Nonnull final Connection connection, @Nonnull final RequestEntry entry ); @Nonnull String getConnectionId(); int getRequestId(); final void onSuccess( final boolean messageComplete, @Nonnull final SafeProcedure onSuccess ); void onFailure( @Nonnull final SafeProcedure onError ); }
Request { public final void onSuccess( final boolean messageComplete, @Nonnull final SafeProcedure onSuccess ) { if ( Replicant.shouldCheckApiInvariants() ) { apiInvariant( () -> !_entry.hasCompleted(), () -> "Replicant-0073: Request.onSuccess invoked on completed request " + _entry + "." ); } _entry.setNormalCompletion( true ); _entry.setExpectingResults( !messageComplete ); _connection.completeRequest( _entry, Objects.requireNonNull( onSuccess ) ); } Request( @Nonnull final Connection connection, @Nonnull final RequestEntry entry ); @Nonnull String getConnectionId(); int getRequestId(); final void onSuccess( final boolean messageComplete, @Nonnull final SafeProcedure onSuccess ); void onFailure( @Nonnull final SafeProcedure onError );  }