public static TokenMatcher opt(TokenMatcher optMatcher) { return new OptTokenMatcher(optMatcher); }
@Test public void shouldMatch() { TokenQueue tokenQueue = spy(new TokenQueue()); TokenMatcher delegate = mock(TokenMatcher.class); OptTokenMatcher matcher = new OptTokenMatcher(delegate); List<Token> output = mock(List.class); assertThat(matcher.matchToken(tokenQueue, output), is(true)); verify(delegate).matchToken(tokenQueue, output); verifyNoMoreInteractions(delegate); verifyNoMoreInteractions(tokenQueue); verifyNoMoreInteractions(output); }
@Test(expected = IllegalArgumentException.class) public void shouldNotAcceptNull() { new OptTokenMatcher(null); }
public static TokenMatcher opt(TokenMatcher optMatcher) { return new OptTokenMatcher(optMatcher); }