Package org.apache.calcite.test
Class Matchers
- java.lang.Object
-
- org.apache.calcite.test.Matchers
-
public class Matchers extends java.lang.Object
Matchers for testing SQL queries.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
Matchers.ComposingMatcher<F,T>
Matcher that transforms the input value using a function before passing to another matcher.static class
Matchers.IsWithin<T extends java.lang.Number>
Is the numeric value within a given difference another value?
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.ThreadLocal<java.lang.Object>
THREAD_ACTUAL
Allows passing the actual result from thematchesSafely
method to thedescribeMismatchSafely
method that will show the difference.
-
Constructor Summary
Constructors Modifier Constructor Description private
Matchers()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <F,T>
org.hamcrest.Matcher<F>compose(org.hamcrest.Matcher<T> matcher, java.util.function.Function<F,T> f)
Creates a matcher by applying a function to a value before calling another matcher.static org.hamcrest.Matcher<java.lang.String>
containsStringLinux(java.lang.String value)
Creates a matcher that matches when the examined string is equal to the specifiedoperand
when all Windows-style line endings ("\r\n") have been converted to Unix-style line endings ("\n").static <E extends java.lang.Comparable>
org.hamcrest.Matcher<java.lang.Iterable<E>>equalsUnordered(E... lines)
static org.hamcrest.Matcher<org.apache.calcite.rel.RelNode>
hasTree(java.lang.String value)
Creates a Matcher that matches aRelNode
its string representation, after converting Windows-style line endings ("\r\n") to Unix-style line endings ("\n"), is equal to the givenvalue
.static org.hamcrest.Matcher<java.lang.String>
isLinux(java.lang.String value)
Creates a Matcher that matches when the examined string is equal to the specifiedvalue
when all Windows-style line endings ("\r\n") have been converted to Unix-style line endings ("\n").static org.hamcrest.Matcher<? super java.sql.ResultSet>
returnsUnordered(java.lang.String... lines)
Creates a matcher that matches if the examined result set returns the given collection of rows in some order.private static <E> java.lang.Iterable<java.lang.String>
toStringList(java.lang.Iterable<E> items)
static <T extends java.lang.Number>
org.hamcrest.Matcher<T>within(T value, double epsilon)
Creates a matcher that matches when the examined object is withinepsilon
of the specifiedoperand
.
-
-
-
Method Detail
-
returnsUnordered
public static org.hamcrest.Matcher<? super java.sql.ResultSet> returnsUnordered(java.lang.String... lines)
Creates a matcher that matches if the examined result set returns the given collection of rows in some order.Closes the result set after reading.
For example:
assertThat(statement.executeQuery("select empno from emp"), returnsUnordered("empno=1234", "empno=100"));
-
equalsUnordered
public static <E extends java.lang.Comparable> org.hamcrest.Matcher<java.lang.Iterable<E>> equalsUnordered(E... lines)
-
toStringList
private static <E> java.lang.Iterable<java.lang.String> toStringList(java.lang.Iterable<E> items)
-
within
public static <T extends java.lang.Number> org.hamcrest.Matcher<T> within(T value, double epsilon)
Creates a matcher that matches when the examined object is withinepsilon
of the specifiedoperand
.
-
compose
public static <F,T> org.hamcrest.Matcher<F> compose(org.hamcrest.Matcher<T> matcher, java.util.function.Function<F,T> f)
Creates a matcher by applying a function to a value before calling another matcher.
-
isLinux
public static org.hamcrest.Matcher<java.lang.String> isLinux(java.lang.String value)
Creates a Matcher that matches when the examined string is equal to the specifiedvalue
when all Windows-style line endings ("\r\n") have been converted to Unix-style line endings ("\n").Thus, if
foo()
is a function that returns "hello{newline}world" in the current operating system's line endings, thenassertThat(foo(), isLinux("hello\nworld"));
will succeed on all platforms.
- See Also:
Util.toLinux(String)
-
hasTree
public static org.hamcrest.Matcher<org.apache.calcite.rel.RelNode> hasTree(java.lang.String value)
Creates a Matcher that matches aRelNode
its string representation, after converting Windows-style line endings ("\r\n") to Unix-style line endings ("\n"), is equal to the givenvalue
.
-
containsStringLinux
public static org.hamcrest.Matcher<java.lang.String> containsStringLinux(java.lang.String value)
Creates a matcher that matches when the examined string is equal to the specifiedoperand
when all Windows-style line endings ("\r\n") have been converted to Unix-style line endings ("\n").Thus, if
foo()
is a function that returns "hello{newline}world" in the current operating system's line endings, thenassertThat(foo(), isLinux("hello\nworld"));
will succeed on all platforms.
- See Also:
Util.toLinux(String)
-
-