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