@Test public void completeMessageResponse() { final Connector connector = createConnector(); final Connection connection = newConnection( connector ); setCurrentMessageResponse( connection, ChangeSetMessage.create( null, null, null, null, null ) ); final TestSpyEventHandler handler = registerTestSpyEventHandler(); connector.completeMessageResponse(); assertNull( connection.getCurrentMessageResponse() ); handler.assertEventCount( 1 ); handler.assertNextEvent( MessageProcessedEvent.class, e -> { assertEquals( e.getSchemaId(), connector.getSchema().getId() ); assertEquals( e.getSchemaName(), connector.getSchema().getName() ); } ); }
void completeMessageResponse() { final Connection connection = ensureConnection(); final MessageResponse response = connection.ensureCurrentMessageResponse(); final RequestEntry request = response.getRequest(); if ( null != request ) { request.markResultsAsArrived(); } final SafeProcedure action = response.getCompletionAction(); if ( null != action ) { action.call(); } final ServerToClientMessage message = response.getMessage(); final Integer requestId = message.getRequestId(); if ( null != requestId ) { connection.removeRequest( requestId ); } connection.setCurrentMessageResponse( null ); onMessageProcessed( response ); callPostMessageResponseActionIfPresent(); if ( null != request ) { final List<AreaOfInterestRequest> requests = connection.getActiveAreaOfInterestRequests(); if ( !requests.isEmpty() ) { if ( requests.get( 0 ).getRequestId() == request.getRequestId() ) { completeAreaOfInterestRequests( requests ); } } } if ( OkMessage.TYPE.equals( message.getType() ) ) { if ( null != requestId && connection.getLastRxSyncRequestId() == requestId ) { if ( connection.syncComplete() ) { onInSync(); getReplicantContext().getConverger().removeOrphanSubscriptions(); } else { onOutOfSync(); } triggerMessageScheduler(); } } else if ( ChangeSetMessage.TYPE.equals( message.getType() ) ) { maybeRequestSync(); final ChangeSetMessage changeSetMessage = (ChangeSetMessage) message; if ( null != changeSetMessage.getETag() ) { cacheMessageIfPossible( response, changeSetMessage ); } } }
Connector extends ReplicantService { void completeMessageResponse() { final Connection connection = ensureConnection(); final MessageResponse response = connection.ensureCurrentMessageResponse(); final RequestEntry request = response.getRequest(); if ( null != request ) { request.markResultsAsArrived(); } final SafeProcedure action = response.getCompletionAction(); if ( null != action ) { action.call(); } final ServerToClientMessage message = response.getMessage(); final Integer requestId = message.getRequestId(); if ( null != requestId ) { connection.removeRequest( requestId ); } connection.setCurrentMessageResponse( null ); onMessageProcessed( response ); callPostMessageResponseActionIfPresent(); if ( null != request ) { final List<AreaOfInterestRequest> requests = connection.getActiveAreaOfInterestRequests(); if ( !requests.isEmpty() ) { if ( requests.get( 0 ).getRequestId() == request.getRequestId() ) { completeAreaOfInterestRequests( requests ); } } } if ( OkMessage.TYPE.equals( message.getType() ) ) { if ( null != requestId && connection.getLastRxSyncRequestId() == requestId ) { if ( connection.syncComplete() ) { onInSync(); getReplicantContext().getConverger().removeOrphanSubscriptions(); } else { onOutOfSync(); } triggerMessageScheduler(); } } else if ( ChangeSetMessage.TYPE.equals( message.getType() ) ) { maybeRequestSync(); final ChangeSetMessage changeSetMessage = (ChangeSetMessage) message; if ( null != changeSetMessage.getETag() ) { cacheMessageIfPossible( response, changeSetMessage ); } } } }
Connector extends ReplicantService { void completeMessageResponse() { final Connection connection = ensureConnection(); final MessageResponse response = connection.ensureCurrentMessageResponse(); final RequestEntry request = response.getRequest(); if ( null != request ) { request.markResultsAsArrived(); } final SafeProcedure action = response.getCompletionAction(); if ( null != action ) { action.call(); } final ServerToClientMessage message = response.getMessage(); final Integer requestId = message.getRequestId(); if ( null != requestId ) { connection.removeRequest( requestId ); } connection.setCurrentMessageResponse( null ); onMessageProcessed( response ); callPostMessageResponseActionIfPresent(); if ( null != request ) { final List<AreaOfInterestRequest> requests = connection.getActiveAreaOfInterestRequests(); if ( !requests.isEmpty() ) { if ( requests.get( 0 ).getRequestId() == request.getRequestId() ) { completeAreaOfInterestRequests( requests ); } } } if ( OkMessage.TYPE.equals( message.getType() ) ) { if ( null != requestId && connection.getLastRxSyncRequestId() == requestId ) { if ( connection.syncComplete() ) { onInSync(); getReplicantContext().getConverger().removeOrphanSubscriptions(); } else { onOutOfSync(); } triggerMessageScheduler(); } } else if ( ChangeSetMessage.TYPE.equals( message.getType() ) ) { maybeRequestSync(); final ChangeSetMessage changeSetMessage = (ChangeSetMessage) message; if ( null != changeSetMessage.getETag() ) { cacheMessageIfPossible( response, changeSetMessage ); } } } Connector( @Nullable final ReplicantContext context,
             @Nonnull final SystemSchema schema,
             @Nonnull final Transport transport ); }
Connector extends ReplicantService { void completeMessageResponse() { final Connection connection = ensureConnection(); final MessageResponse response = connection.ensureCurrentMessageResponse(); final RequestEntry request = response.getRequest(); if ( null != request ) { request.markResultsAsArrived(); } final SafeProcedure action = response.getCompletionAction(); if ( null != action ) { action.call(); } final ServerToClientMessage message = response.getMessage(); final Integer requestId = message.getRequestId(); if ( null != requestId ) { connection.removeRequest( requestId ); } connection.setCurrentMessageResponse( null ); onMessageProcessed( response ); callPostMessageResponseActionIfPresent(); if ( null != request ) { final List<AreaOfInterestRequest> requests = connection.getActiveAreaOfInterestRequests(); if ( !requests.isEmpty() ) { if ( requests.get( 0 ).getRequestId() == request.getRequestId() ) { completeAreaOfInterestRequests( requests ); } } } if ( OkMessage.TYPE.equals( message.getType() ) ) { if ( null != requestId && connection.getLastRxSyncRequestId() == requestId ) { if ( connection.syncComplete() ) { onInSync(); getReplicantContext().getConverger().removeOrphanSubscriptions(); } else { onOutOfSync(); } triggerMessageScheduler(); } } else if ( ChangeSetMessage.TYPE.equals( message.getType() ) ) { maybeRequestSync(); final ChangeSetMessage changeSetMessage = (ChangeSetMessage) message; if ( null != changeSetMessage.getETag() ) { cacheMessageIfPossible( response, changeSetMessage ); } } } Connector( @Nullable final ReplicantContext context,
             @Nonnull final SystemSchema schema,
             @Nonnull final Transport transport ); @Override String toString(); }
Connector extends ReplicantService { void completeMessageResponse() { final Connection connection = ensureConnection(); final MessageResponse response = connection.ensureCurrentMessageResponse(); final RequestEntry request = response.getRequest(); if ( null != request ) { request.markResultsAsArrived(); } final SafeProcedure action = response.getCompletionAction(); if ( null != action ) { action.call(); } final ServerToClientMessage message = response.getMessage(); final Integer requestId = message.getRequestId(); if ( null != requestId ) { connection.removeRequest( requestId ); } connection.setCurrentMessageResponse( null ); onMessageProcessed( response ); callPostMessageResponseActionIfPresent(); if ( null != request ) { final List<AreaOfInterestRequest> requests = connection.getActiveAreaOfInterestRequests(); if ( !requests.isEmpty() ) { if ( requests.get( 0 ).getRequestId() == request.getRequestId() ) { completeAreaOfInterestRequests( requests ); } } } if ( OkMessage.TYPE.equals( message.getType() ) ) { if ( null != requestId && connection.getLastRxSyncRequestId() == requestId ) { if ( connection.syncComplete() ) { onInSync(); getReplicantContext().getConverger().removeOrphanSubscriptions(); } else { onOutOfSync(); } triggerMessageScheduler(); } } else if ( ChangeSetMessage.TYPE.equals( message.getType() ) ) { maybeRequestSync(); final ChangeSetMessage changeSetMessage = (ChangeSetMessage) message; if ( null != changeSetMessage.getETag() ) { cacheMessageIfPossible( response, changeSetMessage ); } } } Connector( @Nullable final ReplicantContext context,
             @Nonnull final SystemSchema schema,
             @Nonnull final Transport transport ); @Override String toString();  }