OmniSciDB  2e3a973ef4
ShowCommandTest.java
Go to the documentation of this file.
1 package com.mapd.parser.extension.ddl;
2 
3 import static org.junit.Assert.assertEquals;
4 
5 import com.google.gson.JsonObject;
6 import com.omnisci.thrift.calciteserver.TPlanResult;
7 
8 import org.junit.Test;
9 
10 public class ShowCommandTest extends DDLTest {
11  public ShowCommandTest() {
12  resourceDirPath = ShowCommandTest.class.getClassLoader().getResource("").getPath();
13  jsonTestDir = "showcommands";
14  }
15 
16  @Test
17  public void showUserSessions() throws Exception {
18  final JsonObject expectedJsonObject = getJsonFromFile("show_user_sessions.json");
19  final TPlanResult result = processDdlCommand("SHOW USER SESSIONS;");
20  final JsonObject actualJsonObject =
21  gson.fromJson(result.plan_result, JsonObject.class);
22  assertEquals(expectedJsonObject, actualJsonObject);
23  }
24 
25  @Test
27  throws Exception {
28  final JsonObject expectedJsonObject = getJsonFromFile("show_tables.json");
29  final TPlanResult result = processDdlCommand("SHOW TABLES;");
30  final JsonObject actualJsonObject =
31  gson.fromJson(result.plan_result, JsonObject.class);
32  assertEquals(expectedJsonObject, actualJsonObject);
33  }
34 
35  @Test
36  public void showDatabases() throws Exception {
37  final JsonObject expectedJsonObject = getJsonFromFile("show_databases.json");
38  final TPlanResult result = processDdlCommand("SHOW DATABASES");
39  final JsonObject actualJsonObject =
40  gson.fromJson(result.plan_result, JsonObject.class);
41  assertEquals(expectedJsonObject, actualJsonObject);
42  }
43 
44  @Test
45  public void showQueries() throws Exception {
46  final JsonObject expectedJsonObject = getJsonFromFile("show_queries.json");
47  final TPlanResult result = processDdlCommand("SHOW QUERIES;");
48  final JsonObject actualJsonObject =
49  gson.fromJson(result.plan_result, JsonObject.class);
50  assertEquals(expectedJsonObject, actualJsonObject);
51  }
52 }
JsonObject getJsonFromFile(final String fileName)
Definition: DDLTest.java:37
TPlanResult processDdlCommand(final String ddlCommand)
Definition: DDLTest.java:32