QueueExporter { public void export() { Set<HandlerKey> handlerKeys = getValidHandlerKeys(listFiles(config.getBufferFile()), config.getExportQueuePorts()); handlerKeys.forEach(this::processHandlerKey); } QueueExporter(ProxyConfig config, TaskQueueFactory taskQueueFactory,
                       EntityPropertiesFactory entityPropertiesFactory); void export();  }
@Test public void testQueueExporterWithRetainData() throws Exception { File file = new File(File.createTempFile("proxyTestConverter", null).getPath() + ".queue"); file.deleteOnExit(); ProxyConfig config = new ProxyConfig(); config.parseArguments(new String[]{ "--flushThreads", "2", "--buffer", file.getAbsolutePath(), "--exportQueuePorts", "2878", "--exportQueueOutputFile", file.getAbsolutePath() + "-output", "--exportQueueRetainData", "true" }, "proxy"); TaskQueueFactory taskQueueFactory = new TaskQueueFactoryImpl(config.getBufferFile(), false); EntityPropertiesFactory entityPropertiesFactory = new EntityPropertiesFactoryImpl(config); QueueExporter qe = new QueueExporter(config, taskQueueFactory, entityPropertiesFactory); BufferedWriter mockedWriter = EasyMock.createMock(BufferedWriter.class); reset(mockedWriter); HandlerKey key = HandlerKey.of(ReportableEntityType.POINT, "2878"); TaskQueue<LineDelimitedDataSubmissionTask> queue = taskQueueFactory.getTaskQueue(key, 0); queue.clear(); UUID proxyId = UUID.randomUUID(); LineDelimitedDataSubmissionTask task = new LineDelimitedDataSubmissionTask(null, proxyId, new DefaultEntityPropertiesForTesting(), queue, "wavefront", ReportableEntityType.POINT, "2878", ImmutableList.of("item1", "item2", "item3"), () -> 12345L); task.enqueue(QueueingReason.RETRY); LineDelimitedDataSubmissionTask task2 = new LineDelimitedDataSubmissionTask(null, proxyId, new DefaultEntityPropertiesForTesting(), queue, "wavefront", ReportableEntityType.POINT, "2878", ImmutableList.of("item4", "item5"), () -> 12345L); task2.enqueue(QueueingReason.RETRY); queue.close(); qe.export(); File outputTextFile = new File(file.getAbsolutePath() + "-output.points.2878.0.txt"); assertEquals(ImmutableList.of("item1", "item2", "item3", "item4", "item5"), Files.asCharSource(outputTextFile, Charsets.UTF_8).readLines()); assertEquals(2, taskQueueFactory.getTaskQueue(key, 0).size()); }