### Question:
QueueBuffer { public synchronized void add(Message message) { linkLast(message); postProcessDeliverableNode(); } QueueBuffer(int inMemoryLimit, int indelibleMessageLimit, MessageReader messageReader); synchronized void add(Message message); synchronized void addAllBareMessages(Collection<Message> messages); synchronized void addBareMessage(Message message); synchronized boolean addIndelibleMessage(Message message); synchronized void remove(long messageId); synchronized void removeAll(Collection<DetachableMessage> messages); int size(); int getNumberOfInflightMessages(); int getNumberOfUndeliveredMessages(); synchronized Message getFirstDeliverable(); void markMessageFilled(Message message); void markMessageFillFailed(Message message); synchronized int clear(Consumer<Message> postDeleteAction);  }### Answer:
@Test public void testAdd() { QueueBuffer queueBuffer = new QueueBuffer(10, 0, messageReader); for (int i = 0; i < 10; i++) { Message message = new Message(i + 1, mockMetadata); queueBuffer.add(message); Assert.assertNotNull(message.getMetadata(), "Message data should not be cleared until the in-memory " + "limit is reached"); } for (int i = 0; i < 3; i++) { Message message = new Message(i + 1, mockMetadata); queueBuffer.add(message); Assert.assertNull(message.getMetadata(), "Message data should be cleared when the queue limit is reached"); } }