SimpleNDCAdapter implements NDCAdapter { @Override @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") public Message[] getContextStack() { List<String> messages = threadLocalMessagePatterns.get(); if(messages == null) { return NO_MESSAGES; } int count=messages.size(); if(count == 0) { clear(); return NO_MESSAGES; } List<String[]> args = threadLocalMessageArguments.get(); Message[] result=new Message[count]; for(int i=0;i<count;i++) { result[i]=new Message(messages.get(i), args.get(i)); } return result; }  @Override void push(String messagePattern, Object... arguments); @Override void pop(); @Override int getDepth(); @Override void setMaximumDepth(int maximumDepth); @Override boolean isEmpty(); @Override void clear(); @Override @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") Message[] getContextStack();  }
@Test public void getContextStackEmpty() { Message[] stack = instance.getContextStack(); assertArrayEquals(new Message[0], stack); }