OmniSciDB  3a86f6ec37
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
26  public void showTables() throws Exception {
27  final JsonObject expectedJsonObject = getJsonFromFile("show_tables.json");
28  final TPlanResult result = processDdlCommand("SHOW TABLES;");
29  final JsonObject actualJsonObject =
30  gson.fromJson(result.plan_result, JsonObject.class);
31  assertEquals(expectedJsonObject, actualJsonObject);
32  }
33 
34  @Test
35  public void showDatabases() throws Exception {
36  final JsonObject expectedJsonObject = getJsonFromFile("show_databases.json");
37  final TPlanResult result = processDdlCommand("SHOW DATABASES;");
38  final JsonObject actualJsonObject =
39  gson.fromJson(result.plan_result, JsonObject.class);
40  assertEquals(expectedJsonObject, actualJsonObject);
41  }
42 
43  @Test
44  public void showQueries() throws Exception {
45  final JsonObject expectedJsonObject = getJsonFromFile("show_queries.json");
46  final TPlanResult result = processDdlCommand("SHOW QUERIES;");
47  final JsonObject actualJsonObject =
48  gson.fromJson(result.plan_result, JsonObject.class);
49  assertEquals(expectedJsonObject, actualJsonObject);
50  }
51 
52  @Test
53  public void showTableDetails() throws Exception {
54  final JsonObject expectedJsonObject = getJsonFromFile("show_table_details.json");
55  final TPlanResult result = processDdlCommand("SHOW TABLE DETAILS;");
56  final JsonObject actualJsonObject =
57  gson.fromJson(result.plan_result, JsonObject.class);
58  assertEquals(expectedJsonObject, actualJsonObject);
59  }
60 
61  @Test
62  public void showTableDetailsForTables() throws Exception {
63  final JsonObject expectedJsonObject =
64  getJsonFromFile("show_table_details_for_tables.json");
65  final TPlanResult result =
66  processDdlCommand("SHOW TABLE DETAILS test_table_1, test_table_2;");
67  final JsonObject actualJsonObject =
68  gson.fromJson(result.plan_result, JsonObject.class);
69  assertEquals(expectedJsonObject, actualJsonObject);
70  }
71 
72  @Test
73  public void showDiskCacheUsage() throws Exception {
74  final JsonObject expectedJsonObject = getJsonFromFile("show_disk_cache_usage.json");
75  final TPlanResult result = processDdlCommand("SHOW DISK CACHE USAGE;");
76  final JsonObject actualJsonObject =
77  gson.fromJson(result.plan_result, JsonObject.class);
78  assertEquals(expectedJsonObject, actualJsonObject);
79  }
80 
81  @Test
82  public void showDiskCacheUsageFor() throws Exception {
83  final JsonObject expectedJsonObject =
84  getJsonFromFile("show_disk_cache_usage_for.json");
85  final TPlanResult result = processDdlCommand("SHOW DISK CACHE USAGE table1, table2;");
86  final JsonObject actualJsonObject =
87  gson.fromJson(result.plan_result, JsonObject.class);
88  assertEquals(expectedJsonObject, actualJsonObject);
89  }
90 }
JsonObject getJsonFromFile(final String fileName)
Definition: DDLTest.java:37
TPlanResult processDdlCommand(final String ddlCommand)
Definition: DDLTest.java:32