Search in sources :

Example 66 with SQLResponse

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()));
}
Also used : SQLResponse(io.crate.testing.SQLResponse) Test(org.junit.Test)

Example 67 with SQLResponse

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]);
}
Also used : SQLResponse(io.crate.testing.SQLResponse)

Example 68 with SQLResponse

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());
}
Also used : SQLResponse(io.crate.testing.SQLResponse)

Example 69 with SQLResponse

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]);
    }
}
Also used : SQLResponse(io.crate.testing.SQLResponse)

Example 70 with SQLResponse

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()));
}
Also used : SQLResponse(io.crate.testing.SQLResponse)

Aggregations

SQLResponse (io.crate.testing.SQLResponse)109 Test (org.junit.Test)78 Map (java.util.Map)13 UseJdbc (io.crate.testing.UseJdbc)10 HashMap (java.util.HashMap)10 ArrayList (java.util.ArrayList)8 PartitionName (io.crate.metadata.PartitionName)4 TestingHelpers.resolveCanonicalString (io.crate.testing.TestingHelpers.resolveCanonicalString)4 Path (java.nio.file.Path)4 BytesRef (org.apache.lucene.util.BytesRef)4 CountDownLatch (java.util.concurrent.CountDownLatch)3 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 TreeMap (java.util.TreeMap)2 List (java.util.List)1 UUID (java.util.UUID)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 ClusterRerouteRequestBuilder (org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteRequestBuilder)1 ClusterStateResponse (org.elasticsearch.action.admin.cluster.state.ClusterStateResponse)1 SearchRequest (org.elasticsearch.action.search.SearchRequest)1 SearchResponse (org.elasticsearch.action.search.SearchResponse)1