PersistenceProcessorHandler implements WorkHandler<PersistenceProcessorImpl.PersistBatchEvent> { public String getId() { return id; } @Inject  PersistenceProcessorHandler(MetricsRegistry metrics,
                                String tsoHostAndPort, // TODO This should not be passed here. Should be part of panicker
                                LeaseManagement leaseManager,
                                CommitTable commitTable,
                                ReplyProcessor replyProcessor,
                                RetryProcessor retryProcessor,
                                Panicker panicker); String getId(); @Override void onEvent(PersistenceProcessorImpl.PersistBatchEvent batchEvent); @Override String toString();  }
@Test(timeOut = 1_000) public void testPersistentProcessorHandlerIdsAreCreatedConsecutive() throws Exception { TSOServerConfig tsoConfig = new TSOServerConfig(); tsoConfig.setNumConcurrentCTWriters(32); PersistenceProcessorHandler[] handlers = new PersistenceProcessorHandler[tsoConfig.getNumConcurrentCTWriters()]; for (int i = 0; i < tsoConfig.getNumConcurrentCTWriters(); i++) { handlers[i] = new PersistenceProcessorHandler(metrics, "localhost:1234", mock(LeaseManager.class), commitTable, mock(ReplyProcessor.class), retryProcessor, panicker); } for (int i = 0; i < tsoConfig.getNumConcurrentCTWriters(); i++) { if (i + 1 < tsoConfig.getNumConcurrentCTWriters()) { int followingHandlerIdAsInt = Integer.valueOf(handlers[i + 1].getId()); assertEquals(handlers[i].getId(), String.valueOf(followingHandlerIdAsInt - 1)); } else { int followingHandlerIdAsInt = PersistenceProcessorHandler.consecutiveSequenceCreator.get(); assertEquals(handlers[i].getId(), String.valueOf(followingHandlerIdAsInt - 1)); } } }