@Test public void completeRequest() { final Connection connection = createConnection(); final RequestEntry request = connection.newRequest( ValueUtil.randomString(), false ); final SafeProcedure action = mock( SafeProcedure.class ); final TestSpyEventHandler handler = registerTestSpyEventHandler(); request.setNormalCompletion( false ); connection.completeRequest( request, action ); verify( action ).call(); assertNull( connection.getRequests().get( request.getRequestId() ) ); handler.assertEventCount( 1 ); handler.assertNextEvent( RequestCompletedEvent.class, ev -> { assertEquals( ev.getSchemaId(), 1 ); assertEquals( ev.getRequestId(), request.getRequestId() ); assertEquals( ev.getName(), request.getName() ); assertFalse( ev.isNormalCompletion() ); assertFalse( ev.isExpectingResults() ); assertFalse( ev.haveResultsArrived() ); } ); }
void completeRequest( @Nonnull final RequestEntry request, @Nonnull final SafeProcedure completionAction ) { if ( request.isExpectingResults() && !request.haveResultsArrived() ) { request.setCompletionAction( completionAction ); } else { if ( !request.isExpectingResults() ) { removeRequest( request.getRequestId() ); } completionAction.call(); } if ( Replicant.areSpiesEnabled() && _connector.getReplicantContext().getSpy().willPropagateSpyEvents() ) { _connector .getReplicantContext() .getSpy() .reportSpyEvent( new RequestCompletedEvent( _connector.getSchema().getId(), _connector.getSchema().getName(), request.getRequestId(), request.getName(), request.isNormalCompletion(), request.isExpectingResults(), request.haveResultsArrived() ) ); } }
Connection { void completeRequest( @Nonnull final RequestEntry request, @Nonnull final SafeProcedure completionAction ) { if ( request.isExpectingResults() && !request.haveResultsArrived() ) { request.setCompletionAction( completionAction ); } else { if ( !request.isExpectingResults() ) { removeRequest( request.getRequestId() ); } completionAction.call(); } if ( Replicant.areSpiesEnabled() && _connector.getReplicantContext().getSpy().willPropagateSpyEvents() ) { _connector .getReplicantContext() .getSpy() .reportSpyEvent( new RequestCompletedEvent( _connector.getSchema().getId(), _connector.getSchema().getName(), request.getRequestId(), request.getName(), request.isNormalCompletion(), request.isExpectingResults(), request.haveResultsArrived() ) ); } } }
Connection { void completeRequest( @Nonnull final RequestEntry request, @Nonnull final SafeProcedure completionAction ) { if ( request.isExpectingResults() && !request.haveResultsArrived() ) { request.setCompletionAction( completionAction ); } else { if ( !request.isExpectingResults() ) { removeRequest( request.getRequestId() ); } completionAction.call(); } if ( Replicant.areSpiesEnabled() && _connector.getReplicantContext().getSpy().willPropagateSpyEvents() ) { _connector .getReplicantContext() .getSpy() .reportSpyEvent( new RequestCompletedEvent( _connector.getSchema().getId(), _connector.getSchema().getName(), request.getRequestId(), request.getName(), request.isNormalCompletion(), request.isExpectingResults(), request.haveResultsArrived() ) ); } } Connection( @Nonnull final Connector connector ); }
Connection { void completeRequest( @Nonnull final RequestEntry request, @Nonnull final SafeProcedure completionAction ) { if ( request.isExpectingResults() && !request.haveResultsArrived() ) { request.setCompletionAction( completionAction ); } else { if ( !request.isExpectingResults() ) { removeRequest( request.getRequestId() ); } completionAction.call(); } if ( Replicant.areSpiesEnabled() && _connector.getReplicantContext().getSpy().willPropagateSpyEvents() ) { _connector .getReplicantContext() .getSpy() .reportSpyEvent( new RequestCompletedEvent( _connector.getSchema().getId(), _connector.getSchema().getName(), request.getRequestId(), request.getName(), request.isNormalCompletion(), request.isExpectingResults(), request.haveResultsArrived() ) ); } } Connection( @Nonnull final Connector connector );  }
Connection { void completeRequest( @Nonnull final RequestEntry request, @Nonnull final SafeProcedure completionAction ) { if ( request.isExpectingResults() && !request.haveResultsArrived() ) { request.setCompletionAction( completionAction ); } else { if ( !request.isExpectingResults() ) { removeRequest( request.getRequestId() ); } completionAction.call(); } if ( Replicant.areSpiesEnabled() && _connector.getReplicantContext().getSpy().willPropagateSpyEvents() ) { _connector .getReplicantContext() .getSpy() .reportSpyEvent( new RequestCompletedEvent( _connector.getSchema().getId(), _connector.getSchema().getName(), request.getRequestId(), request.getName(), request.isNormalCompletion(), request.isExpectingResults(), request.haveResultsArrived() ) ); } } Connection( @Nonnull final Connector connector );   }