IOThread implements Runnable, AutoCloseable { public void tick() { ConnectionState oldState = connectionState; connectionState = cycle(connectionState); if (thread == null) oldConnectionsDrainer.checkOldConnections(); if (thread != null) sleepIfProblemsGettingSyncedConnection(connectionState, oldState); } IOThread(ThreadGroup ioThreadGroup,
             Endpoint endpoint,
             EndpointResultQueue endpointResultQueue,
             GatewayConnectionFactory connectionFactory,
             int clusterId,
             int maxChunkSizeBytes,
             int maxInFlightRequests,
             Duration localQueueTimeOut,
             DocumentQueue documentQueue,
             long maxSleepTimeMs,
             Duration connectionTimeToLive,
             boolean runThreads,
             double idlePollFrequency,
             Clock clock); Endpoint getEndpoint(); ConnectionStats getConnectionStats(); @Override void close(); void post(Document document); @Override String toString(); @Override void run(); void tick(); GatewayConnection currentConnection(); List<GatewayConnection> oldConnections(); EndpointResultQueue resultQueue();  }
@Test public void testSuccessfulWriting() { OperationProcessorTester tester = new OperationProcessorTester(); assertEquals(0, tester.incomplete()); assertEquals(0, tester.success()); assertEquals(0, tester.failures()); tester.send("doc1"); tester.send("doc2"); tester.send("doc3"); assertEquals(3, tester.incomplete()); assertEquals(0, tester.success()); assertEquals(0, tester.failures()); tester.tick(1); assertEquals(3, tester.incomplete()); tester.tick(1); assertEquals(3, tester.incomplete()); tester.tick(1); assertEquals(0, tester.incomplete()); assertEquals(3, tester.success()); assertEquals(0, tester.failures()); }