OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AlterDatabaseTest.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.Gson;
6 import com.google.gson.JsonObject;
8 
9 import org.junit.Test;
10 
11 import ai.heavy.thrift.calciteserver.TPlanResult;
12 
13 public class AlterDatabaseTest extends DDLTest {
14  public AlterDatabaseTest() {
15  resourceDirPath = AlterDatabaseTest.class.getClassLoader().getResource("").getPath();
16  jsonTestDir = "database";
17  }
18 
19  @Test
20  public void AlterDatabaseChangeOwner() throws Exception {
21  final JsonObject expectedJsonObject =
22  getJsonFromFile("alter_database_change_owner.json");
23  final TPlanResult result =
24  processDdlCommand("ALTER DATABASE test_database OWNER TO Joe;");
25  final JsonObject actualJsonObject =
26  gson.fromJson(result.plan_result, JsonObject.class);
27 
28  assertEquals(expectedJsonObject, actualJsonObject);
29  }
30 
31  @Test
32  public void AlterDatabaseRename() throws Exception {
33  final JsonObject expectedJsonObject = getJsonFromFile("alter_database_rename.json");
34  final TPlanResult result =
35  processDdlCommand("ALTER DATABASE my_database RENAME TO my_new_database;");
36  final JsonObject actualJsonObject =
37  gson.fromJson(result.plan_result, JsonObject.class);
38 
39  assertEquals(expectedJsonObject, actualJsonObject);
40  }
41 }
JsonObject getJsonFromFile(final String fileName)
Definition: DDLTest.java:51
TPlanResult processDdlCommand(final String ddlCommand)
Definition: DDLTest.java:35