Package org.sonar.duplications.token

Examples of org.sonar.duplications.token.TokenQueue


  @Test
  public void shouldNotMatch() {
    Token t1 = new Token("a", 1, 1);
    Token t2 = new Token("b", 2, 1);
    TokenQueue tokenQueue = spy(new TokenQueue(Arrays.asList(t1, t2)));
    List<Token> output = mock(List.class);
    UptoTokenMatcher matcher = new UptoTokenMatcher(new String[] { ";" });

    assertThat(matcher.matchToken(tokenQueue, output), is(false));
    verify(tokenQueue, times(2)).poll();
View Full Code Here


  @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);
  }
View Full Code Here

  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);
View Full Code Here

    StatementChannel.create(new TokenMatcher[] {});
  }

  @Test
  public void shouldPushForward() {
    TokenQueue tokenQueue = mock(TokenQueue.class);
    TokenMatcher matcher = mock(TokenMatcher.class);
    List<Statement> output = mock(List.class);
    StatementChannel channel = StatementChannel.create(matcher);

    assertThat(channel.consume(tokenQueue, output), is(false));
View Full Code Here

  }

  @Test
  public void shouldCreateStatement() {
    Token token = new Token("a", 1, 1);
    TokenQueue tokenQueue = spy(new TokenQueue(Arrays.asList(token)));
    TokenMatcher matcher = spy(new AnyTokenMatcher());
    StatementChannel channel = StatementChannel.create(matcher);
    List<Statement> output = mock(List.class);

    assertThat(channel.consume(tokenQueue, output), is(true));
View Full Code Here

    verifyNoMoreInteractions(output);
  }

  @Test
  public void shouldNotCreateStatement() {
    TokenQueue tokenQueue = spy(new TokenQueue(Arrays.asList(new Token("a", 1, 1))));
    TokenMatcher matcher = spy(new AnyTokenMatcher());
    StatementChannel channel = StatementChannel.create(matcher);
    List<Statement> output = mock(List.class);

    assertThat(channel.consume(tokenQueue, output), is(true));
View Full Code Here

TOP

Related Classes of org.sonar.duplications.token.TokenQueue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.