public boolean consume(TokenQueue tokenQueue, List<Statement> statements) {
    Token nextToken = tokenQueue.peek();
    while (nextToken != null) {
      boolean channelConsumed = false;
      for (StatementChannel channel : channels) {
        if (channel.consume(tokenQueue, statements)) {
          channelConsumed = true;
          break;
        }
      }
      if (!channelConsumed) {
        throw new IllegalStateException("None of the statement channel has been able to consume token: " + nextToken);
      }
      nextToken = tokenQueue.peek();
    }
    return true;
  }
@Test
  public void shouldConsume() {
    TokenMatcher tokenMatcher = mock(TokenMatcher.class);
    when(tokenMatcher.matchToken(any(TokenQueue.class), anyList())).thenReturn(true);
    StatementChannel channel = StatementChannel.create(tokenMatcher);
    StatementChannelDisptacher dispatcher = new StatementChannelDisptacher(asList(channel));
    TokenQueue tokenQueue = mock(TokenQueue.class);
    when(tokenQueue.peek()).thenReturn(new Token("a", 1, 0)).thenReturn(null);
    List<Statement> statements = mock(List.class);

    assertThat(dispatcher.consume(tokenQueue, statements), is(true));
    verify(tokenQueue, times(2)).peek();
    verifyNoMoreInteractions(tokenQueue);
    verifyNoMoreInteractions(statements);
  }