### Question:
AsyncLogWriter implements ApptentiveLog.LogListener { @Override public void onLogMessage(@NonNull ApptentiveLog.Level level, @NonNull String message) { synchronized (mutex) { pendingMessages.add(level.getShortName() + ": " + message); writeQueue.dispatchAsyncOnce(writeQueueTask); } } AsyncLogWriter(File destDir, int logHistorySize);   AsyncLogWriter(File destDir, DispatchQueue writeQueue, int logHistorySize); @Override void onLogMessage(@NonNull ApptentiveLog.Level level, @NonNull String message);  }### Answer:
@Test public void testWritingLogs() { File destDir = tempDir.getRoot(); MockAsyncLogWriter writer; writer = new MockAsyncLogWriter(destDir, 3); writer.onLogMessage(ERROR, "あ"); writer.onLogMessage(DEBUG, "い"); writer.onLogMessage(INFO, "う"); assertFiles(listLogFiles(destDir), "あ\nい\nう\n"); writer = new MockAsyncLogWriter(destDir, 3); writer.onLogMessage(ERROR, "1"); writer.onLogMessage(DEBUG, "2"); writer.onLogMessage(INFO, "3"); assertFiles(listLogFiles(destDir), "あ\nい\nう\n", "1\n2\n3\n"); writer = new MockAsyncLogWriter(destDir, 3); writer.onLogMessage(ERROR, "4"); writer.onLogMessage(DEBUG, "5"); writer.onLogMessage(INFO, "6"); assertFiles(listLogFiles(destDir), "あ\nい\nう\n", "1\n2\n3\n", "4\n5\n6\n"); writer = new MockAsyncLogWriter(destDir, 3); writer.onLogMessage(ERROR, "7"); writer.onLogMessage(DEBUG, "8"); writer.onLogMessage(INFO, "9"); assertFiles(listLogFiles(destDir), "1\n2\n3\n", "4\n5\n6\n", "7\n8\n9\n"); writer = new MockAsyncLogWriter(destDir, 3); writer.onLogMessage(ERROR, "10"); writer.onLogMessage(DEBUG, "11"); writer.onLogMessage(INFO, "12"); assertFiles(listLogFiles(destDir), "4\n5\n6\n", "7\n8\n9\n", "10\n11\n12\n"); writer = new MockAsyncLogWriter(destDir, 3); writer.onLogMessage(ERROR, "13"); writer.onLogMessage(DEBUG, "14"); writer.onLogMessage(INFO, "15"); assertFiles(listLogFiles(destDir), "7\n8\n9\n", "10\n11\n12\n", "13\n14\n15\n"); }