LocationTokens { public List<Token> tokensOfType(TokenType... tokenTypes) { List<Token> tokensOfType = new ArrayList<>(); for (Token token : getTokens()) { for (int i = 0; i < tokenTypes.length; i++) { if (tokenTypes[i].equals(token.getType())) { tokensOfType.add(token); } } } return tokensOfType; } 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 testTokensOfType() { List<Token> tokenList = locationTokens.tokensOfType(TokenType.AND); assertThat(tokenList.size()).isEqualTo(0); tokenList = locationTokens.tokensOfType(TokenType.HOUSE_NUMBER); assertThat(tokenList.size()).isEqualTo(1); assertThat(tokenList).contains(houseNumberToken); tokenList = locationTokens.tokensOfType(TokenType.STREET_NAME); assertThat(tokenList.size()).isEqualTo(1); assertThat(tokenList).contains(streetNameToken); tokenList = locationTokens.tokensOfType(TokenType.BOROUGH_NAME); assertThat(tokenList.size()).isEqualTo(1); assertThat(tokenList).contains(boroughToken); tokenList = locationTokens.tokensOfType(TokenType.HOUSE_NUMBER, TokenType.STREET_NAME); assertThat(tokenList.size()).isEqualTo(2); assertThat(tokenList).contains(houseNumberToken); assertThat(tokenList).contains(streetNameToken); }