|
|
@ -9,7 +9,7 @@ public class FilterCompilerTest { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void filter_compiler_test() { |
|
|
|
public void valid_filters_compile() { |
|
|
|
assertThat(compile("[?(@)]").toString()).isEqualTo("[?(@)]"); |
|
|
|
assertThat(compile("[?(@)]").toString()).isEqualTo("[?(@)]"); |
|
|
|
assertThat(compile("[?(@)]").toString()).isEqualTo("[?(@)]"); |
|
|
|
assertThat(compile("[?(@)]").toString()).isEqualTo("[?(@)]"); |
|
|
|
assertThat(compile("[?(@.firstname)]").toString()).isEqualTo("[?(@['firstname'])]"); |
|
|
|
assertThat(compile("[?(@.firstname)]").toString()).isEqualTo("[?(@['firstname'])]"); |
|
|
@ -40,5 +40,28 @@ public class FilterCompilerTest { |
|
|
|
assertThat(compile("[?(@.message.%min()==10)]").toString()).isEqualTo("[?(@['message'].%min() == 10)]"); |
|
|
|
assertThat(compile("[?(@.message.%min()==10)]").toString()).isEqualTo("[?(@['message'].%min() == 10)]"); |
|
|
|
assertThat(compile("[?(10 == @.message.%min())]").toString()).isEqualTo("[?(10 == @['message'].%min())]"); |
|
|
|
assertThat(compile("[?(10 == @.message.%min())]").toString()).isEqualTo("[?(10 == @['message'].%min())]"); |
|
|
|
assertThat(compile("[?(((@)))]").toString()).isEqualTo("[?(@)]"); |
|
|
|
assertThat(compile("[?(((@)))]").toString()).isEqualTo("[?(@)]"); |
|
|
|
|
|
|
|
assertThat(compile("[?(@.name =~ /.*?/i)]").toString()).isEqualTo("[?(@['name'] =~ /.*?/i)]"); |
|
|
|
|
|
|
|
assertThat(compile("[?(@.name =~ /.*?/)]").toString()).isEqualTo("[?(@['name'] =~ /.*?/)]"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void invalid_filters_does_not_compile() { |
|
|
|
|
|
|
|
assertInvalidPathException("[?(@))]"); |
|
|
|
|
|
|
|
assertInvalidPathException("[?(@ FOO 1)]"); |
|
|
|
|
|
|
|
assertInvalidPathException("[?(@ || )]"); |
|
|
|
|
|
|
|
assertInvalidPathException("[?(@ == 'foo )]"); |
|
|
|
|
|
|
|
assertInvalidPathException("[?(@ == 1' )]"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void assertInvalidPathException(String filter){ |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
compile(filter); |
|
|
|
|
|
|
|
throw new AssertionError("Expected " + filter + " to throw InvalidPathException"); |
|
|
|
|
|
|
|
} catch (InvalidPathException e){ |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|