use of io.prestosql.testing.TestingWarningCollector in project hetu-core by openlookeng.
the class TestJdbcWarnings method testStatementWarnings.
@Test
public void testStatementWarnings() throws SQLException {
assertFalse(statement.execute("CREATE SCHEMA blackhole.test_schema"));
SQLWarning warning = statement.getWarnings();
assertNotNull(warning);
TestingWarningCollectorConfig warningCollectorConfig = new TestingWarningCollectorConfig().setPreloadedWarnings(PRELOADED_WARNINGS);
TestingWarningCollector warningCollector = new TestingWarningCollector(new WarningCollectorConfig(), warningCollectorConfig);
List<PrestoWarning> expectedWarnings = warningCollector.getWarnings();
assertStartsWithExpectedWarnings(warning, fromPrestoWarnings(expectedWarnings));
statement.clearWarnings();
assertNull(statement.getWarnings());
}
use of io.prestosql.testing.TestingWarningCollector in project hetu-core by openlookeng.
the class TestJdbcWarnings method testExecuteQueryWarnings.
@Test
public void testExecuteQueryWarnings() throws SQLException {
try (ResultSet rs = statement.executeQuery("SELECT a FROM (VALUES 1, 2, 3) t(a)")) {
assertNull(statement.getConnection().getWarnings());
assertNull(statement.getWarnings());
assertNull(rs.getWarnings());
Set<WarningEntry> currentWarnings = new HashSet<>();
while (rs.next()) {
assertWarnings(rs.getWarnings(), currentWarnings);
}
TestingWarningCollectorConfig warningCollectorConfig = new TestingWarningCollectorConfig().setPreloadedWarnings(PRELOADED_WARNINGS).setAddWarnings(true);
TestingWarningCollector warningCollector = new TestingWarningCollector(new WarningCollectorConfig(), warningCollectorConfig);
List<PrestoWarning> expectedWarnings = warningCollector.getWarnings();
for (PrestoWarning prestoWarning : expectedWarnings) {
assertTrue(currentWarnings.contains(new WarningEntry(toPrestoSqlWarning(prestoWarning))));
}
}
}
use of io.prestosql.testing.TestingWarningCollector in project hetu-core by openlookeng.
the class TestTestingWarningCollector method testAddWarnings.
@Test
public void testAddWarnings() {
TestingWarningCollector collector = new TestingWarningCollector(new WarningCollectorConfig(), new TestingWarningCollectorConfig().setAddWarnings(true));
ImmutableList.Builder<PrestoWarning> expectedWarningsBuilder = ImmutableList.builder();
expectedWarningsBuilder.add(createTestWarning(1));
assertEquals(collector.getWarnings(), expectedWarningsBuilder.build());
}
use of io.prestosql.testing.TestingWarningCollector in project hetu-core by openlookeng.
the class TestCompletedEventWarnings method testCompletedEventWarnings.
@Test
public void testCompletedEventWarnings() throws InterruptedException {
TestingWarningCollectorConfig warningCollectorConfig = new TestingWarningCollectorConfig().setPreloadedWarnings(TEST_WARNINGS);
TestingWarningCollector testingWarningCollector = new TestingWarningCollector(new WarningCollectorConfig(), warningCollectorConfig);
assertWarnings("select 1", ImmutableMap.of(), testingWarningCollector.getWarnings().stream().map(PrestoWarning::getWarningCode).collect(toImmutableList()));
}
Aggregations