@Test(expected = IllegalStateException.class)
  public void shouldThrowAnException() {
    TokenMatcher tokenMatcher = mock(TokenMatcher.class);
    StatementChannel channel = StatementChannel.create(tokenMatcher);
    StatementChannelDisptacher dispatcher = new StatementChannelDisptacher(Arrays.asList(channel));
    TokenQueue tokenQueue = mock(TokenQueue.class);
    when(tokenQueue.peek()).thenReturn(new Token("a", 1, 0)).thenReturn(null);
    List<Statement> statements = mock(List.class);

    dispatcher.consume(tokenQueue, statements);
  }
  @Test
  public void shouldConsume() {
    TokenMatcher tokenMatcher = mock(TokenMatcher.class);
    when(tokenMatcher.matchToken(any(TokenQueue.class), anyListOf(Token.class))).thenReturn(true);
    StatementChannel channel = StatementChannel.create(tokenMatcher);
    StatementChannelDisptacher dispatcher = new StatementChannelDisptacher(Arrays.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);
  }