### Question:
MessageTracker { public void dumpToLog(String serverAddress) { if (!enabled) { return; } logMessages(serverAddress, receivedBuffer, Direction.RECEIVED); logMessages(serverAddress, sentBuffer, Direction.SENT); } MessageTracker(int buffer_size); void trackSent(long timestamp); void trackSent(int packetType); void trackReceived(long timestamp); void trackReceived(int packetType); final BufferedMessage peekSent(); final BufferedMessage peekReceived(); final long peekSentTimestamp(); final long peekReceivedTimestamp(); void dumpToLog(String serverAddress); static final String MESSAGE_TRACKER_BUFFER_SIZE; static final String MESSAGE_TRACKER_ENABLED; static final int BUFFERED_MESSAGE_SIZE; }### Answer:
@Test public void testDumpToLog() { long timestamp1 = System.currentTimeMillis(); MessageTracker messageTracker = new MessageTracker(BUFFERED_MESSAGE_SIZE); String sid = "127.0.0.1"; messageTracker.dumpToLog(sid); assertNull(messageTracker.peekSent()); assertNull(messageTracker.peekReceived()); messageTracker.trackSent(timestamp1); assertEquals(messageTracker.peekSentTimestamp(), timestamp1); assertNull(messageTracker.peekReceived()); messageTracker.dumpToLog(sid); assertNull(messageTracker.peekSent()); assertNull(messageTracker.peekReceived()); messageTracker.trackSent(timestamp1); messageTracker.trackReceived(timestamp1); assertEquals(messageTracker.peekSentTimestamp(), timestamp1); assertEquals(messageTracker.peekReceivedTimestamp(), timestamp1); messageTracker.dumpToLog(sid); assertNull(messageTracker.peekSent()); assertNull(messageTracker.peekReceived()); }