@SuppressWarnings( { "unchecked" } ) @Test public void progressResponseProcessing() { final ChannelSchema channelSchema = new ChannelSchema( 0, ValueUtil.randomString(), null, ChannelSchema.FilterType.NONE, null, false, true, Collections.emptyList() ); final EntitySchema.Creator<Linkable> creator = mock( EntitySchema.Creator.class ); final EntitySchema.Updater<Linkable> updater = mock( EntitySchema.Updater.class ); final EntitySchema entitySchema = new EntitySchema( 0, ValueUtil.randomString(), Linkable.class, creator, updater ); final SystemSchema schema = new SystemSchema( 1, ValueUtil.randomString(), new ChannelSchema[]{ channelSchema }, new EntitySchema[]{ entitySchema } ); final Connector connector = createConnector( schema ); final Connection connection = newConnection( connector ); final ChangeSetMessage message = ChangeSetMessage.create( null, null, new String[]{ "+0" }, null, new EntityChange[]{ EntityChange.create( 0, 1, new String[]{ "0" }, new EntityChangeDataImpl() ) } ); connection.enqueueResponse( message, null ); assertNull( connection.getCurrentMessageResponse() ); assertEquals( connection.getPendingResponses().size(), 1 ); final MessageResponse response = connection.getPendingResponses().get( 0 ); assertTrue( connector.progressResponseProcessing() ); assertEquals( connection.getCurrentMessageResponse(), response ); assertEquals( connection.getPendingResponses().size(), 0 ); { assertTrue( response.needsChannelChangesProcessed() ); assertTrue( connector.progressResponseProcessing() ); assertFalse( response.needsChannelChangesProcessed() ); } { assertTrue( response.areEntityChangesPending() ); when( creator.createEntity( anyInt(), any( EntityChangeData.class ) ) ).thenReturn( mock( Linkable.class ) ); assertTrue( connector.progressResponseProcessing() ); assertFalse( response.areEntityChangesPending() ); } { assertTrue( response.areEntityLinksPending() ); assertTrue( connector.progressResponseProcessing() ); assertFalse( response.areEntityLinksPending() ); } { assertFalse( response.hasWorldBeenValidated() ); assertTrue( connector.progressResponseProcessing() ); assertTrue( response.hasWorldBeenValidated() ); } { assertEquals( connection.getCurrentMessageResponse(), response ); assertTrue( connector.progressResponseProcessing() ); assertNull( connection.getCurrentMessageResponse() ); } }
boolean progressResponseProcessing() { final Connection connection = ensureConnection(); final MessageResponse response = connection.getCurrentMessageResponse(); if ( null == response ) { return connection.selectNextMessageResponse(); } else if ( response.needsChannelChangesProcessed() ) { processChannelChanges(); return true; } else if ( response.areEntityChangesPending() ) { processEntityChanges(); return true; } else if ( response.areEntityLinksPending() ) { processEntityLinks(); return true; } else if ( !response.hasWorldBeenValidated() ) { releaseSchedulerLock(); validateWorld(); return true; } else { releaseSchedulerLock(); completeMessageResponse(); return true; } }
Connector extends ReplicantService { boolean progressResponseProcessing() { final Connection connection = ensureConnection(); final MessageResponse response = connection.getCurrentMessageResponse(); if ( null == response ) { return connection.selectNextMessageResponse(); } else if ( response.needsChannelChangesProcessed() ) { processChannelChanges(); return true; } else if ( response.areEntityChangesPending() ) { processEntityChanges(); return true; } else if ( response.areEntityLinksPending() ) { processEntityLinks(); return true; } else if ( !response.hasWorldBeenValidated() ) { releaseSchedulerLock(); validateWorld(); return true; } else { releaseSchedulerLock(); completeMessageResponse(); return true; } } }
Connector extends ReplicantService { boolean progressResponseProcessing() { final Connection connection = ensureConnection(); final MessageResponse response = connection.getCurrentMessageResponse(); if ( null == response ) { return connection.selectNextMessageResponse(); } else if ( response.needsChannelChangesProcessed() ) { processChannelChanges(); return true; } else if ( response.areEntityChangesPending() ) { processEntityChanges(); return true; } else if ( response.areEntityLinksPending() ) { processEntityLinks(); return true; } else if ( !response.hasWorldBeenValidated() ) { releaseSchedulerLock(); validateWorld(); return true; } else { releaseSchedulerLock(); completeMessageResponse(); return true; } } Connector( @Nullable final ReplicantContext context,
             @Nonnull final SystemSchema schema,
             @Nonnull final Transport transport ); }
Connector extends ReplicantService { boolean progressResponseProcessing() { final Connection connection = ensureConnection(); final MessageResponse response = connection.getCurrentMessageResponse(); if ( null == response ) { return connection.selectNextMessageResponse(); } else if ( response.needsChannelChangesProcessed() ) { processChannelChanges(); return true; } else if ( response.areEntityChangesPending() ) { processEntityChanges(); return true; } else if ( response.areEntityLinksPending() ) { processEntityLinks(); return true; } else if ( !response.hasWorldBeenValidated() ) { releaseSchedulerLock(); validateWorld(); return true; } else { releaseSchedulerLock(); completeMessageResponse(); return true; } } Connector( @Nullable final ReplicantContext context,
             @Nonnull final SystemSchema schema,
             @Nonnull final Transport transport ); @Override String toString(); }
Connector extends ReplicantService { boolean progressResponseProcessing() { final Connection connection = ensureConnection(); final MessageResponse response = connection.getCurrentMessageResponse(); if ( null == response ) { return connection.selectNextMessageResponse(); } else if ( response.needsChannelChangesProcessed() ) { processChannelChanges(); return true; } else if ( response.areEntityChangesPending() ) { processEntityChanges(); return true; } else if ( response.areEntityLinksPending() ) { processEntityLinks(); return true; } else if ( !response.hasWorldBeenValidated() ) { releaseSchedulerLock(); validateWorld(); return true; } else { releaseSchedulerLock(); completeMessageResponse(); return true; } } Connector( @Nullable final ReplicantContext context,
             @Nonnull final SystemSchema schema,
             @Nonnull final Transport transport ); @Override String toString();  }