LocationTokens { public String parseSummary() { Deque<String> stack = new ArrayDeque<>(); for (Chunk chunk : chunks) { StringBuffer chunkBuffer = new StringBuffer(); chunkBuffer.append(chunk.getType()); chunkBuffer.append("{ "); for (Iterator<Token> iter = chunk.getTokens().iterator(); iter.hasNext();) { Token token = iter.next(); chunkBuffer.append(String.format("%s[%s]", token.getType(), token.getValue())); if (iter.hasNext()) { chunkBuffer.append(", "); } } chunkBuffer.append(" }"); stack.push(chunkBuffer.toString()); } StringBuffer buff = new StringBuffer(); for (Iterator<String> iter = stack.iterator(); iter.hasNext();) { buff.append(iter.next()); if (iter.hasNext()) { buff.append(", "); } } return String.format("%s", buff.toString()); } LocationTokens(Input input, List<Chunk> chunks); List<Token> tokensOfType(TokenType... tokenTypes); Token firstTokenOfType(TokenType tokenType); Input getInput(); List<Chunk> getChunks(); List<Token> getTokens(); String parseSummary(); @Override String toString();  }
@Test public void testParseSummary() { assertThat(locationTokens.parseSummary()).isEqualTo("ADDRESS{ HOUSE_NUMBER[22], STREET_NAME[Broadway] }, COUNTY{ BOROUGH_NAME[Manhattan] }"); }