use of io.crate.testing.SQLResponse in project crate by crate.
the class SysCheckerIntegrationTest method testChecksPresenceAndSeverityLevels.
@Test
public void testChecksPresenceAndSeverityLevels() throws Exception {
SQLResponse response = execute("select severity, passed from sys.checks order by id asc");
assertThat(response.rowCount(), equalTo(4L));
assertThat(response.rows()[0][0], is(Severity.HIGH.value()));
assertThat(response.rows()[1][0], is(Severity.MEDIUM.value()));
assertThat(response.rows()[2][0], is(Severity.MEDIUM.value()));
assertThat(response.rows()[3][0], is(Severity.MEDIUM.value()));
}
use of io.crate.testing.SQLResponse in project crate by crate.
the class TransportSQLActionClassLifecycleTest method testGlobalAggregateMany.
@Test
public void testGlobalAggregateMany() throws Exception {
SQLResponse response = execute("select sum(age), min(age), max(age), avg(age) from characters");
assertEquals(1, response.rowCount());
assertEquals(221.0d, response.rows()[0][0]);
assertEquals(32, response.rows()[0][1]);
assertEquals(112, response.rows()[0][2]);
assertEquals(55.25d, response.rows()[0][3]);
}
use of io.crate.testing.SQLResponse in project crate by crate.
the class TransportSQLActionClassLifecycleTest method testGroupByAndOrderByAlias.
@Test
public void testGroupByAndOrderByAlias() throws Exception {
SQLResponse response = execute("select characters.race as test_race from characters group by characters.race order by characters.race");
assertEquals(3, response.rowCount());
response = execute("select characters.race as test_race from characters group by characters.race order by test_race");
assertEquals(3, response.rowCount());
}
use of io.crate.testing.SQLResponse in project crate by crate.
the class TransportSQLActionClassLifecycleTest method testArithmeticFunctions.
@Test
public void testArithmeticFunctions() throws Exception {
SQLResponse response = execute("select ((2 * 4 - 2 + 1) / 2) % 3 from sys.cluster");
assertThat(response.cols()[0], is("(((((2 * 4) - 2) + 1) / 2) % 3)"));
assertThat((Long) response.rows()[0][0], is(0L));
response = execute("select ((2 * 4.0 - 2 + 1) / 2) % 3 from sys.cluster");
assertThat((Double) response.rows()[0][0], is(0.5));
response = execute("select ? + 2 from sys.cluster", $(1));
assertThat((Long) response.rows()[0][0], is(3L));
if (!Constants.WINDOWS) {
response = execute("select load['1'] + load['5'], load['1'], load['5'] from sys.nodes limit 1");
assertEquals(response.rows()[0][0], (Double) response.rows()[0][1] + (Double) response.rows()[0][2]);
}
}
use of io.crate.testing.SQLResponse in project crate by crate.
the class TransportSQLActionClassLifecycleTest method testSelectRawWithGrouping.
@Test
public void testSelectRawWithGrouping() throws Exception {
SQLResponse response = execute("select name, _raw from characters " + "group by _raw, name order by name desc limit 1");
assertEquals("Trillian| {\"race\":\"Human\",\"gender\":\"female\",\"age\":32,\"birthdate\":276912000000," + "\"name\":\"Trillian\",\"details\":{\"job\":\"Mathematician\"}}\n", TestingHelpers.printedTable(response.rows()));
}
Aggregations