OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
7 import org.junit.Test;
8 
9 import ai.heavy.thrift.calciteserver.TPlanResult;
10 
11 public class ShowCommandTest extends DDLTest {
12  public ShowCommandTest() {
13  resourceDirPath = ShowCommandTest.class.getClassLoader().getResource("").getPath();
14  jsonTestDir = "showcommands";
15  }
16 
17  @Test
18  public void showUserSessions() throws Exception {
19  final JsonObject expectedJsonObject = getJsonFromFile("show_user_sessions.json");
20  final TPlanResult result = processDdlCommand("SHOW USER SESSIONS;");
21  final JsonObject actualJsonObject =
22  gson.fromJson(result.plan_result, JsonObject.class);
23  assertEquals(expectedJsonObject, actualJsonObject);
24  }
25 
26  @Test
27  public void showUserDetails() throws Exception {
28  final JsonObject expectedJsonObject = getJsonFromFile("show_user_details.json");
29  final TPlanResult result = processDdlCommand("SHOW USER DETAILS;");
30  final JsonObject actualJsonObject =
31  gson.fromJson(result.plan_result, JsonObject.class);
32  assertEquals(expectedJsonObject, actualJsonObject);
33  }
34 
35  @Test
36  public void showUserDetailsForUser() throws Exception {
37  final JsonObject expectedJsonObject =
38  getJsonFromFile("show_user_details_for_user.json");
39  final TPlanResult result =
40  processDdlCommand("SHOW USER DETAILS test_user1, test_user2;");
41  final JsonObject actualJsonObject =
42  gson.fromJson(result.plan_result, JsonObject.class);
43  assertEquals(expectedJsonObject, actualJsonObject);
44  }
45 
46  @Test
47  public void showAllUserDetails() throws Exception {
48  final JsonObject expectedJsonObject = getJsonFromFile("show_all_user_details.json");
49  final TPlanResult result = processDdlCommand("SHOW ALL USER DETAILS;");
50  final JsonObject actualJsonObject =
51  gson.fromJson(result.plan_result, JsonObject.class);
52  assertEquals(expectedJsonObject, actualJsonObject);
53  }
54 
55  @Test
56  public void showAllUserDetailsForUser() throws Exception {
57  final JsonObject expectedJsonObject =
58  getJsonFromFile("show_all_user_details_for_user.json");
59  final TPlanResult result =
60  processDdlCommand("SHOW ALL USER DETAILS test_user1, test_user2;");
61  final JsonObject actualJsonObject =
62  gson.fromJson(result.plan_result, JsonObject.class);
63  assertEquals(expectedJsonObject, actualJsonObject);
64  }
65 
66  @Test
67  public void showTables() throws Exception {
68  final JsonObject expectedJsonObject = getJsonFromFile("show_tables.json");
69  final TPlanResult result = processDdlCommand("SHOW TABLES;");
70  final JsonObject actualJsonObject =
71  gson.fromJson(result.plan_result, JsonObject.class);
72  assertEquals(expectedJsonObject, actualJsonObject);
73  }
74 
75  @Test
76  public void showDatabases() throws Exception {
77  final JsonObject expectedJsonObject = getJsonFromFile("show_databases.json");
78  final TPlanResult result = processDdlCommand("SHOW DATABASES;");
79  final JsonObject actualJsonObject =
80  gson.fromJson(result.plan_result, JsonObject.class);
81  assertEquals(expectedJsonObject, actualJsonObject);
82  }
83 
84  @Test
85  public void showQueries() throws Exception {
86  final JsonObject expectedJsonObject = getJsonFromFile("show_queries.json");
87  final TPlanResult result = processDdlCommand("SHOW QUERIES;");
88  final JsonObject actualJsonObject =
89  gson.fromJson(result.plan_result, JsonObject.class);
90  assertEquals(expectedJsonObject, actualJsonObject);
91  }
92 
93  @Test
94  public void showTableDetails() throws Exception {
95  final JsonObject expectedJsonObject = getJsonFromFile("show_table_details.json");
96  final TPlanResult result = processDdlCommand("SHOW TABLE DETAILS;");
97  final JsonObject actualJsonObject =
98  gson.fromJson(result.plan_result, JsonObject.class);
99  assertEquals(expectedJsonObject, actualJsonObject);
100  }
101 
102  @Test
103  public void showTableDetailsForTables() throws Exception {
104  final JsonObject expectedJsonObject =
105  getJsonFromFile("show_table_details_for_tables.json");
106  final TPlanResult result =
107  processDdlCommand("SHOW TABLE DETAILS test_table_1, test_table_2;");
108  final JsonObject actualJsonObject =
109  gson.fromJson(result.plan_result, JsonObject.class);
110  assertEquals(expectedJsonObject, actualJsonObject);
111  }
112 
113  @Test
114  public void showDiskCacheUsage() throws Exception {
115  final JsonObject expectedJsonObject = getJsonFromFile("show_disk_cache_usage.json");
116  final TPlanResult result = processDdlCommand("SHOW DISK CACHE USAGE;");
117  final JsonObject actualJsonObject =
118  gson.fromJson(result.plan_result, JsonObject.class);
119  assertEquals(expectedJsonObject, actualJsonObject);
120  }
121 
122  @Test
123  public void showDiskCacheUsageFor() throws Exception {
124  final JsonObject expectedJsonObject =
125  getJsonFromFile("show_disk_cache_usage_for.json");
126  final TPlanResult result = processDdlCommand("SHOW DISK CACHE USAGE table1, table2;");
127  final JsonObject actualJsonObject =
128  gson.fromJson(result.plan_result, JsonObject.class);
129  assertEquals(expectedJsonObject, actualJsonObject);
130  }
131 
132  @Test
133  public void showSupportedDataSources() throws Exception {
134  final JsonObject expectedJsonObject = getJsonFromFile("show_data_sources.json");
135  final TPlanResult result = processDdlCommand("SHOW SUPPORTED DATA SOURCES;");
136  final JsonObject actualJsonObject =
137  gson.fromJson(result.plan_result, JsonObject.class);
138  assertEquals(expectedJsonObject, actualJsonObject);
139  }
140 }
JsonObject getJsonFromFile(final String fileName)
Definition: DDLTest.java:51
TPlanResult processDdlCommand(final String ddlCommand)
Definition: DDLTest.java:35