@Test public void testFuzzyScript() { Handle h = dbRule.openHandle(); Script script = h.createScript(getResourceOnClasspath("script/fuzzy-script.sql")); script.executeAsSeparateStatements(); List<Map<String, Object>> rows = h.select("select id, name from something order by id").mapToMap().list(); assertThat(rows).isEqualTo(ImmutableList.of( ImmutableMap.of("id", 1L, "name", "eric"), ImmutableMap.of("id", 2L, "name", "sally;ann"), ImmutableMap.of("id", 3L, "name", "bob"), ImmutableMap.of("id", 12L, "name", "sally;ann;junior"))); }
@Test public void testScriptAsSetOfSeparateStatements() { assertThatExceptionOfType(StatementException.class) .isThrownBy(() -> { Handle h = dbRule.openHandle(); Script script = h.createScript(getResourceOnClasspath("script/malformed-sql-script.sql")); script.executeAsSeparateStatements(); }) .satisfies(e -> assertThat(e.getStatementContext().getRawSql().trim()) .isEqualTo("insert into something(id, name) values (2, eric)")); } }