Search in sources :

Example 1 with TimeZoneNotSupportedException

use of com.facebook.presto.spi.type.TimeZoneNotSupportedException in project presto by prestodb.

the class TestServer method testInvalidSessionError.

@Test
public void testInvalidSessionError() throws Exception {
    String invalidTimeZone = "this_is_an_invalid_time_zone";
    Request request = preparePost().setHeader(PRESTO_USER, "user").setUri(uriFor("/v1/statement")).setBodyGenerator(createStaticBodyGenerator("show catalogs", UTF_8)).setHeader(PRESTO_SOURCE, "source").setHeader(PRESTO_CATALOG, "catalog").setHeader(PRESTO_SCHEMA, "schema").setHeader(PRESTO_TIME_ZONE, invalidTimeZone).build();
    QueryResults queryResults = client.execute(request, createJsonResponseHandler(jsonCodec(QueryResults.class)));
    QueryError queryError = queryResults.getError();
    assertNotNull(queryError);
    TimeZoneNotSupportedException expected = new TimeZoneNotSupportedException(invalidTimeZone);
    assertEquals(queryError.getErrorCode(), expected.getErrorCode().getCode());
    assertEquals(queryError.getErrorName(), expected.getErrorCode().getName());
    assertEquals(queryError.getErrorType(), expected.getErrorCode().getType().name());
    assertEquals(queryError.getMessage(), expected.getMessage());
}
Also used : Request(io.airlift.http.client.Request) QueryError(com.facebook.presto.client.QueryError) TimeZoneNotSupportedException(com.facebook.presto.spi.type.TimeZoneNotSupportedException) QueryResults(com.facebook.presto.client.QueryResults) Test(org.testng.annotations.Test)

Aggregations

QueryError (com.facebook.presto.client.QueryError)1 QueryResults (com.facebook.presto.client.QueryResults)1 TimeZoneNotSupportedException (com.facebook.presto.spi.type.TimeZoneNotSupportedException)1 Request (io.airlift.http.client.Request)1 Test (org.testng.annotations.Test)1