XPathParser { protected Operator parseGeneralComp( TokenStream tokens ) { if (tokens.canConsume("!", "=")) return Operator.NOT_EQUAL_TO; if (tokens.canConsume("=")) return Operator.EQUAL_TO; if (tokens.canConsume("<", "=")) return Operator.LESS_THAN_OR_EQUAL_TO; if (tokens.canConsume(">", "=")) return Operator.GREATER_THAN_OR_EQUAL_TO; if (tokens.canConsume("<")) return Operator.LESS_THAN; if (tokens.canConsume(">")) return Operator.GREATER_THAN; return null; } XPathParser( TypeSystem context ); Component parseXPath( String xpath );  }
@Test public void shouldParseGeneralComp() { assertThat(parser.parseGeneralComp(tokenize("!=")), is(Operator.NOT_EQUAL_TO)); assertThat(parser.parseGeneralComp(tokenize("=")), is(Operator.EQUAL_TO)); assertThat(parser.parseGeneralComp(tokenize("<")), is(Operator.LESS_THAN)); assertThat(parser.parseGeneralComp(tokenize("<=")), is(Operator.LESS_THAN_OR_EQUAL_TO)); assertThat(parser.parseGeneralComp(tokenize(">")), is(Operator.GREATER_THAN)); assertThat(parser.parseGeneralComp(tokenize(">=")), is(Operator.GREATER_THAN_OR_EQUAL_TO)); assertThat(parser.parseGeneralComp(tokenize("<5")), is(Operator.LESS_THAN)); assertThat(parser.parseGeneralComp(tokenize(">5")), is(Operator.GREATER_THAN)); }
@Test public void shouldReturnNullFromParseGeneralCompIfOperatorPatternIsNotFound() { assertThat(parser.parseGeneralComp(tokenize("name")), is(nullValue())); assertThat(parser.parseGeneralComp(tokenize("+")), is(nullValue())); assertThat(parser.parseGeneralComp(tokenize("!+")), is(nullValue())); }