1 package com.mapd.parser.extension.ddl;
3 import static org.junit.Assert.assertEquals;
5 import com.google.gson.JsonObject;
9 import ai.heavy.thrift.calciteserver.InvalidParseRequest;
10 import ai.heavy.thrift.calciteserver.TPlanResult;
14 resourceDirPath = UserMappingTest.class.getClassLoader().getResource(
"").getPath();
20 final JsonObject expectedJsonObject =
getJsonFromFile(
"create_user_mapping.json");
22 "CREATE USER MAPPING FOR test_user SERVER test_server WITH (attribute_1 = 'value_1', attribute_2 = 2);");
23 final JsonObject actualJsonObject =
24 gson.fromJson(result.plan_result, JsonObject.class);
26 assertEquals(expectedJsonObject, actualJsonObject);
31 final JsonObject expectedJsonObject =
34 "CREATE USER MAPPING FOR CURRENT_USER SERVER test_server WITH (attribute_1 = 'value_1', attribute_2 = 2);");
35 final JsonObject actualJsonObject =
36 gson.fromJson(result.plan_result, JsonObject.class);
38 assertEquals(expectedJsonObject, actualJsonObject);
43 final JsonObject expectedJsonObject =
46 "CREATE USER MAPPING FOR PUBLIC SERVER test_server WITH (attribute_1 = 'value_1', attribute_2 = 2);");
47 final JsonObject actualJsonObject =
48 gson.fromJson(result.plan_result, JsonObject.class);
50 assertEquals(expectedJsonObject, actualJsonObject);
55 final JsonObject expectedJsonObject =
58 "CREATE USER MAPPING IF NOT EXISTS FOR test_user SERVER test_server "
59 +
"WITH (attribute_1 = 'value_1', attribute_2 = 2);");
60 final JsonObject actualJsonObject =
61 gson.fromJson(result.plan_result, JsonObject.class);
63 assertEquals(expectedJsonObject, actualJsonObject);
66 @Test(expected = InvalidParseRequest.class)
71 @Test(expected = InvalidParseRequest.class)
73 processDdlCommand(
"CREATE USER MAPPING FOR test_user SERVER test_server WITH ();");
78 final JsonObject expectedJsonObject =
getJsonFromFile(
"drop_user_mapping.json");
81 final JsonObject actualJsonObject =
82 gson.fromJson(result.plan_result, JsonObject.class);
84 assertEquals(expectedJsonObject, actualJsonObject);
89 final JsonObject expectedJsonObject =
92 "DROP USER MAPPING IF EXISTS FOR test_user SERVER test_server;");
93 final JsonObject actualJsonObject =
94 gson.fromJson(result.plan_result, JsonObject.class);
96 assertEquals(expectedJsonObject, actualJsonObject);
JsonObject getJsonFromFile(final String fileName)
void dropUserMappingWithIfExists()
void createUserMappingEmptyOptions()
TPlanResult processDdlCommand(final String ddlCommand)
void createUserMappingForCurrentUser()
void createUserMappingForPublicUser()
void createUserMappingNoWithClause()
void createUserMappingWithIfNotExists()