MCPcopy Create free account
hub / github.com/apache/calcite / testHook

Method testHook

core/src/test/java/org/apache/calcite/test/JdbcTest.java:7772–7793  ·  view source on GitHub ↗

Tests that Hook#PARSE_TREE works.

()

Source from the content-addressed store, hash-verified

7770
7771 /** Tests that {@link Hook#PARSE_TREE} works. */
7772 @Test void testHook() {
7773 final int[] callCount = {0};
7774 try (Hook.Closeable ignored =
7775 Hook.PARSE_TREE.<Object[]>addThread(args -> {
7776 assertThat(args, arrayWithSize(2));
7777 assertThat(args[0], instanceOf(String.class));
7778 assertThat(args[0],
7779 is("select \"deptno\", \"commission\", sum(\"salary\") s\n"
7780 + "from \"hr\".\"emps\"\n"
7781 + "group by \"deptno\", \"commission\""));
7782 assertThat(args[1], instanceOf(SqlSelect.class));
7783 ++callCount[0];
7784 })) {
7785 // Simple query does not run the hook.
7786 testSimple();
7787 assertThat(callCount[0], is(0));
7788
7789 // Non-trivial query runs hook once.
7790 testGroupByNull();
7791 assertThat(callCount[0], is(1));
7792 }
7793 }
7794
7795 /** Tests {@link SqlDialect}. */
7796 @Test void testDialect() {

Callers

nothing calls this directly

Calls 4

testSimpleMethod · 0.95
testGroupByNullMethod · 0.95
addThreadMethod · 0.80
isMethod · 0.80

Tested by

no test coverage detected