TokenStream { public String consume() throws ParsingException, IllegalStateException { if (completed) throwNoMoreContent(); String result = currentToken().value(); moveToNextToken(); return result; } TokenStream( String content,
                        Tokenizer tokenizer,
                        boolean caseSensitive ); TokenStream start(); void rewind(); Position previousPosition(); Position nextPosition(); int consumeInteger(); long consumeLong(); boolean consumeBoolean(); String consume(); void consume( String expected ); void consume( char expected ); void consume( int expectedType ); void consume( String expected,
                         String... expectedForNextTokens ); void consume( String[] nextTokens ); void consume( Iterable<String> nextTokens ); boolean canConsume( String expected ); boolean canConsume( char expected ); boolean canConsume( int expectedType ); boolean canConsume( String currentExpected,
                               String... expectedForNextTokens ); boolean canConsume( String[] nextTokens ); boolean canConsume( Iterable<String> nextTokens ); boolean canConsumeAnyOf( String firstOption,
                                    String... additionalOptions ); boolean canConsumeAnyOf( String[] options ); boolean canConsumeAnyOf( Iterable<String> options ); boolean canConsumeAnyOf( int firstTypeOption,
                                    int... additionalTypeOptions ); boolean canConsumeAnyOf( int[] typeOptions ); boolean matches( String expected ); boolean matches( char expected ); boolean matches( int expectedType ); boolean matches( String currentExpected,
                            String... expectedForNextTokens ); boolean matches( String[] nextTokens ); boolean matches( Iterable<String> nextTokens ); boolean matches( int currentExpectedType,
                            int... expectedTypeForNextTokens ); boolean matches( int[] typesForNextTokens ); boolean matchesAnyOf( String firstOption,
                                 String... additionalOptions ); boolean matchesAnyOf( String[] options ); boolean matchesAnyOf( Iterable<String> options ); boolean matchesAnyOf( int firstTypeOption,
                                 int... additionalTypeOptions ); boolean matchesAnyOf( int[] typeOptions ); boolean hasNext(); @Override String toString(); String getContentBetween( Position starting,
                                     Position end ); static BasicTokenizer basicTokenizer( boolean includeComments ); static final String ANY_VALUE; static final int ANY_TYPE; }
@Test( expected = ParsingException.class ) public void shouldFailToConsumeInCaseSensitiveMannerWithExpectedValuesWhenMatchingIncorrectCase() { makeCaseSensitive(); tokens.consume("Select"); tokens.consume("all"); tokens.consume("Columns"); }
@Test( expected = ParsingException.class ) public void shouldFailToConsumeInCaseInsensitiveMannerWithExpectedValuesWhenMatchingStringIsInLowerCase() { makeCaseInsensitive(); tokens.consume("SELECT"); tokens.consume("ALL"); tokens.consume("columns"); }
@FixFor( "MODE-2497" ) @Test public void shouldConsumeCaseInsensitiveStringInOriginalCase() { makeCaseInsensitive(); String firstToken = tokens.consume(); assertThat(firstToken, is("Select")); }
@Test( expected = ParsingException.class ) public void shouldFailToConsumeMultipleTokensIfTheyDoNotMatch() { makeCaseInsensitive(); tokens.consume("SELECT", "ALL", "COLUMNS", "FROM", "TABLE"); }