use of io.trino.spi.TrinoWarning in project trino by trinodb.
the class TestDefaultWarningCollector method testMaxWarnings.
@Test
public void testMaxWarnings() {
WarningCollector warningCollector = new DefaultWarningCollector(new WarningCollectorConfig().setMaxWarnings(2));
warningCollector.add(new TrinoWarning(new WarningCode(1, "1"), "warning 1"));
warningCollector.add(new TrinoWarning(new WarningCode(2, "2"), "warning 2"));
warningCollector.add(new TrinoWarning(new WarningCode(3, "3"), "warning 3"));
assertEquals(warningCollector.getWarnings().size(), 2);
}
use of io.trino.spi.TrinoWarning in project trino by trinodb.
the class TestTestingWarningCollector method testAddWarnings.
@Test
public void testAddWarnings() {
TestingWarningCollector collector = new TestingWarningCollector(new WarningCollectorConfig(), new TestingWarningCollectorConfig().setAddWarnings(true));
ImmutableList.Builder<TrinoWarning> expectedWarningsBuilder = ImmutableList.builder();
expectedWarningsBuilder.add(createTestWarning(1));
assertEquals(collector.getWarnings(), expectedWarningsBuilder.build());
}
use of io.trino.spi.TrinoWarning in project trino by trinodb.
the class TestDefaultWarningCollector method testNoWarnings.
@Test
public void testNoWarnings() {
WarningCollector warningCollector = new DefaultWarningCollector(new WarningCollectorConfig().setMaxWarnings(0));
warningCollector.add(new TrinoWarning(new WarningCode(1, "1"), "warning 1"));
assertEquals(warningCollector.getWarnings().size(), 0);
}
use of io.trino.spi.TrinoWarning in project trino by trinodb.
the class TestJdbcWarnings method testSqlWarning.
@Test
public void testSqlWarning() {
ImmutableList.Builder<TrinoWarning> builder = ImmutableList.builder();
for (int i = 0; i < 3; i++) {
builder.add(new TrinoWarning(new WarningCode(i, "CODE_" + i), "warning message " + i));
}
List<TrinoWarning> warnings = builder.build();
SQLWarning warning = fromTrinoWarnings(warnings);
assertEquals(Iterators.size(warning.iterator()), warnings.size());
assertWarningsEqual(warning, toTrinoSqlWarning(warnings.get(0)));
assertWarningsEqual(warning.getNextWarning(), toTrinoSqlWarning(warnings.get(1)));
assertWarningsEqual(warning.getNextWarning().getNextWarning(), toTrinoSqlWarning(warnings.get(2)));
}
use of io.trino.spi.TrinoWarning in project trino by trinodb.
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(TrinoWarning::getWarningCode).collect(toImmutableList()));
}
Aggregations