World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#6416] improve(CLI): Add schema command context CLI (#6427)
Lord of Abyss086278e8f93f
diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/GravitinoCommandLine.java b/clients/cli/src/main/java/org/apache/gravitino/cli/GravitinoCommandLine.javaindex 3106c3ea50..5ab3ed5c93 100644--- a/clients/cli/src/main/java/org/apache/gravitino/cli/GravitinoCommandLine.java+++ b/clients/cli/src/main/java/org/apache/gravitino/cli/GravitinoCommandLine.java@@ -120,7 +120,7 @@ public class GravitinoCommandLine extends TestableCommandLine {} else if (entity.equals(CommandEntities.TABLE)) {new TableCommandHandler(this, line, command, context).handle();} else if (entity.equals(CommandEntities.SCHEMA)) {- new SchemaCommandHandler(this, line, command, ignore).handle();+ new SchemaCommandHandler(this, line, command, context).handle();} else if (entity.equals(CommandEntities.CATALOG)) {new CatalogCommandHandler(this, line, command, ignore).handle();} else if (entity.equals(CommandEntities.METALAKE)) {diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/SchemaCommandHandler.java b/clients/cli/src/main/java/org/apache/gravitino/cli/SchemaCommandHandler.javaindex 4a0cf919fb..4b6a11496e 100644--- a/clients/cli/src/main/java/org/apache/gravitino/cli/SchemaCommandHandler.java+++ b/clients/cli/src/main/java/org/apache/gravitino/cli/SchemaCommandHandler.java@@ -29,8 +29,7 @@ public class SchemaCommandHandler extends CommandHandler {private final GravitinoCommandLine gravitinoCommandLine;private final CommandLine line;private final String command;- private final boolean ignore;- private final String url;+ private final CommandContext context;private final FullName name;private final String metalake;private final String catalog;@@ -42,16 +41,19 @@ public class SchemaCommandHandler extends CommandHandler {* @param gravitinoCommandLine The Gravitino command line instance.* @param line The command line arguments.* @param command The command to execute.- * @param ignore Ignore server version mismatch.+ * @param context The command context.*/public SchemaCommandHandler(- GravitinoCommandLine gravitinoCommandLine, CommandLine line, String command, boolean ignore) {+ GravitinoCommandLine gravitinoCommandLine,+ CommandLine line,+ String command,+ CommandContext context) {this.gravitinoCommandLine = gravitinoCommandLine;this.line = line;this.command = command;- this.ignore = ignore;+ this.context = context;- this.url = getUrl(line);+ this.context.setUrl(getUrl(line));this.name = new FullName(line);this.metalake = name.getMetalakeName();this.catalog = name.getCatalogName();@@ -120,21 +122,15 @@ public class SchemaCommandHandler extends CommandHandler {/** Handles the "LIST" command. */private void handleListCommand() {- gravitinoCommandLine.newListSchema(url, ignore, metalake, catalog).validate().handle();+ gravitinoCommandLine.newListSchema(context, metalake, catalog).validate().handle();}/** Handles the "DETAILS" command. */private void handleDetailsCommand() {if (line.hasOption(GravitinoOptions.AUDIT)) {- gravitinoCommandLine- .newSchemaAudit(url, ignore, metalake, catalog, schema)- .validate()- .handle();+ gravitinoCommandLine.newSchemaAudit(context, metalake, catalog, schema).validate().handle();} else {- gravitinoCommandLine- .newSchemaDetails(url, ignore, metalake, catalog, schema)- .validate()- .handle();+ gravitinoCommandLine.newSchemaDetails(context, metalake, catalog, schema).validate().handle();}}@@ -142,18 +138,14 @@ public class SchemaCommandHandler extends CommandHandler {private void handleCreateCommand() {String comment = line.getOptionValue(GravitinoOptions.COMMENT);gravitinoCommandLine- .newCreateSchema(url, ignore, metalake, catalog, schema, comment)+ .newCreateSchema(context, metalake, catalog, schema, comment).validate().handle();}/** Handles the "DELETE" command. */private void handleDeleteCommand() {- boolean force = line.hasOption(GravitinoOptions.FORCE);- gravitinoCommandLine- .newDeleteSchema(url, ignore, force, metalake, catalog, schema)- .validate()- .handle();+ gravitinoCommandLine.newDeleteSchema(context, metalake, catalog, schema).validate().handle();}/** Handles the "SET" command. */@@ -161,7 +153,7 @@ public class SchemaCommandHandler extends CommandHandler {String property = line.getOptionValue(GravitinoOptions.PROPERTY);String value = line.getOptionValue(GravitinoOptions.VALUE);gravitinoCommandLine- .newSetSchemaProperty(url, ignore, metalake, catalog, schema, property, value)+ .newSetSchemaProperty(context, metalake, catalog, schema, property, value).validate().handle();}@@ -170,7 +162,7 @@ public class SchemaCommandHandler extends CommandHandler {private void handleRemoveCommand() {String property = line.getOptionValue(GravitinoOptions.PROPERTY);gravitinoCommandLine- .newRemoveSchemaProperty(url, ignore, metalake, catalog, schema, property)+ .newRemoveSchemaProperty(context, metalake, catalog, schema, property).validate().handle();}@@ -178,7 +170,7 @@ public class SchemaCommandHandler extends CommandHandler {/** Handles the "PROPERTIES" command. */private void handlePropertiesCommand() {gravitinoCommandLine- .newListSchemaProperties(url, ignore, metalake, catalog, schema)+ .newListSchemaProperties(context, metalake, catalog, schema).validate().handle();}diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/TestableCommandLine.java b/clients/cli/src/main/java/org/apache/gravitino/cli/TestableCommandLine.javaindex 58dc0ac9e8..de2583f698 100644--- a/clients/cli/src/main/java/org/apache/gravitino/cli/TestableCommandLine.java+++ b/clients/cli/src/main/java/org/apache/gravitino/cli/TestableCommandLine.java@@ -260,48 +260,47 @@ public class TestableCommandLine {}protected SchemaAudit newSchemaAudit(- String url, boolean ignore, String metalake, String catalog, String schema) {- return new SchemaAudit(url, ignore, metalake, catalog, schema);+ CommandContext context, String metalake, String catalog, String schema) {+ return new SchemaAudit(context, metalake, catalog, schema);}protected SchemaDetails newSchemaDetails(- String url, boolean ignore, String metalake, String catalog, String schema) {- return new SchemaDetails(url, ignore, metalake, catalog, schema);+ CommandContext context, String metalake, String catalog, String schema) {+ return new SchemaDetails(context, metalake, catalog, schema);}- protected ListSchema newListSchema(String url, boolean ignore, String metalake, String catalog) {- return new ListSchema(url, ignore, metalake, catalog);+ protected ListSchema newListSchema(CommandContext context, String metalake, String catalog) {+ return new ListSchema(context, metalake, catalog);}protected CreateSchema newCreateSchema(- String url, boolean ignore, String metalake, String catalog, String schema, String comment) {- return new CreateSchema(url, ignore, metalake, catalog, schema, comment);+ CommandContext context, String metalake, String catalog, String schema, String comment) {+ return new CreateSchema(context, metalake, catalog, schema, comment);}protected DeleteSchema newDeleteSchema(- String url, boolean ignore, boolean force, String metalake, String catalog, String schema) {- return new DeleteSchema(url, ignore, force, metalake, catalog, schema);+ CommandContext context, String metalake, String catalog, String schema) {+ return new DeleteSchema(context, metalake, catalog, schema);}protected SetSchemaProperty newSetSchemaProperty(- String url,- boolean ignore,+ CommandContext context,String metalake,String catalog,String schema,String property,String value) {- return new SetSchemaProperty(url, ignore, metalake, catalog, schema, property, value);+ return new SetSchemaProperty(context, metalake, catalog, schema, property, value);}protected RemoveSchemaProperty newRemoveSchemaProperty(- String url, boolean ignore, String metalake, String catalog, String schema, String property) {- return new RemoveSchemaProperty(url, ignore, metalake, catalog, schema, property);+ CommandContext context, String metalake, String catalog, String schema, String property) {+ return new RemoveSchemaProperty(context, metalake, catalog, schema, property);}protected ListSchemaProperties newListSchemaProperties(- String url, boolean ignore, String metalake, String catalog, String schema) {- return new ListSchemaProperties(url, ignore, metalake, catalog, schema);+ CommandContext context, String metalake, String catalog, String schema) {+ return new ListSchemaProperties(context, metalake, catalog, schema);}protected TableAudit newTableAudit(diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/CreateSchema.java b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/CreateSchema.javaindex 34243c1e4e..532130403e 100644--- a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/CreateSchema.java+++ b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/CreateSchema.java@@ -19,6 +19,7 @@package org.apache.gravitino.cli.commands;+import org.apache.gravitino.cli.CommandContext;import org.apache.gravitino.cli.ErrorMessages;import org.apache.gravitino.client.GravitinoClient;import org.apache.gravitino.exceptions.NoSuchCatalogException;@@ -34,21 +35,15 @@ public class CreateSchema extends Command {/*** Create a new schema.*- * @param url The URL of the Gravitino server.- * @param ignoreVersions If true don't check the client/server versions match.+ * @param context The command context.* @param metalake The name of the metalake.* @param catalog The name of the catalog.* @param schema The name of the schema.* @param comment The schema's comment.*/public CreateSchema(- String url,- boolean ignoreVersions,- String metalake,- String catalog,- String schema,- String comment) {- super(url, ignoreVersions);+ CommandContext context, String metalake, String catalog, String schema, String comment) {+ super(context);this.metalake = metalake;this.catalog = catalog;this.schema = schema;@@ -71,6 +66,6 @@ public class CreateSchema extends Command {exitWithError(exp.getMessage());}- System.out.println(schema + " created");+ printInformation(schema + " created");}}diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/DeleteSchema.java b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/DeleteSchema.javaindex 826bdba2fb..1454419676 100644--- a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/DeleteSchema.java+++ b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/DeleteSchema.java@@ -20,6 +20,7 @@package org.apache.gravitino.cli.commands;import org.apache.gravitino.cli.AreYouSure;+import org.apache.gravitino.cli.CommandContext;import org.apache.gravitino.cli.ErrorMessages;import org.apache.gravitino.client.GravitinoClient;import org.apache.gravitino.exceptions.NoSuchCatalogException;@@ -36,22 +37,14 @@ public class DeleteSchema extends Command {/*** Delete a schema.*- * @param url The URL of the Gravitino server.- * @param ignoreVersions If true don't check the client/server versions match.- * @param force Force operation.+ * @param context The command context.* @param metalake The name of the metalake.* @param catalog The name of the catalog.* @param schema The name of the schema.*/- public DeleteSchema(- String url,- boolean ignoreVersions,- boolean force,- String metalake,- String catalog,- String schema) {- super(url, ignoreVersions);- this.force = force;+ public DeleteSchema(CommandContext context, String metalake, String catalog, String schema) {+ super(context);+ this.force = context.force();this.metalake = metalake;this.catalog = catalog;this.schema = schema;@@ -80,9 +73,9 @@ public class DeleteSchema extends Command {}if (deleted) {- System.out.println(schema + " deleted.");+ printInformation(schema + " deleted.");} else {- System.out.println(schema + " not deleted.");+ printInformation(schema + " not deleted.");}}}diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListSchema.java b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListSchema.javaindex 695f44d42d..bbc881ce06 100644--- a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListSchema.java+++ b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListSchema.java@@ -20,6 +20,7 @@package org.apache.gravitino.cli.commands;import com.google.common.base.Joiner;+import org.apache.gravitino.cli.CommandContext;import org.apache.gravitino.cli.ErrorMessages;import org.apache.gravitino.client.GravitinoClient;import org.apache.gravitino.exceptions.NoSuchCatalogException;@@ -34,13 +35,12 @@ public class ListSchema extends Command {/*** Lists all schemas in a catalog.*- * @param url The URL of the Gravitino server.- * @param ignoreVersions If true don't check the client/server versions match.+ * @param context The command context.* @param metalake The name of the metalake.* @param catalog The name of the catalog.*/- public ListSchema(String url, boolean ignoreVersions, String metalake, String catalog) {- super(url, ignoreVersions);+ public ListSchema(CommandContext context, String metalake, String catalog) {+ super(context);this.metalake = metalake;this.catalog = catalog;}@@ -62,6 +62,6 @@ public class ListSchema extends Command {String all = schemas.length == 0 ? "No schemas exist." : Joiner.on(",").join(schemas);- System.out.println(all);+ printInformation(all);}}diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListSchemaProperties.java b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListSchemaProperties.javaindex 76a99b8eb6..ff28d4970c 100644--- a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListSchemaProperties.java+++ b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListSchemaProperties.java@@ -21,6 +21,7 @@ package org.apache.gravitino.cli.commands;import java.util.Map;import org.apache.gravitino.Schema;+import org.apache.gravitino.cli.CommandContext;import org.apache.gravitino.cli.ErrorMessages;import org.apache.gravitino.client.GravitinoClient;import org.apache.gravitino.exceptions.NoSuchCatalogException;@@ -37,15 +38,14 @@ public class ListSchemaProperties extends ListProperties {/*** List the properties of a schema.*- * @param url The URL of the Gravitino server.- * @param ignoreVersions If true don't check the client/server versions match.+ * @param context The command context.* @param metalake The name of the metalake.* @param catalog The name of the catalog.* @param schema The name of the schema.*/public ListSchemaProperties(- String url, boolean ignoreVersions, String metalake, String catalog, String schema) {- super(url, ignoreVersions);+ CommandContext context, String metalake, String catalog, String schema) {+ super(context);this.metalake = metalake;this.catalog = catalog;this.schema = schema;diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/RemoveSchemaProperty.java b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/RemoveSchemaProperty.javaindex 8fedcb6216..7a7c9dd62d 100644--- a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/RemoveSchemaProperty.java+++ b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/RemoveSchemaProperty.java@@ -20,6 +20,7 @@package org.apache.gravitino.cli.commands;import org.apache.gravitino.SchemaChange;+import org.apache.gravitino.cli.CommandContext;import org.apache.gravitino.cli.ErrorMessages;import org.apache.gravitino.client.GravitinoClient;import org.apache.gravitino.exceptions.NoSuchCatalogException;@@ -37,21 +38,15 @@ public class RemoveSchemaProperty extends Command {/*** Remove a property of a schema.*- * @param url The URL of the Gravitino server.- * @param ignoreVersions If true don't check the client/server versions match.+ * @param context The command context.* @param metalake The name of the metalake.* @param catalog The name of the catalog.* @param schema The name of the schema.* @param property The name of the property.*/public RemoveSchemaProperty(- String url,- boolean ignoreVersions,- String metalake,- String catalog,- String schema,- String property) {- super(url, ignoreVersions);+ CommandContext context, String metalake, String catalog, String schema, String property) {+ super(context);this.metalake = metalake;this.catalog = catalog;this.schema = schema;@@ -75,7 +70,7 @@ public class RemoveSchemaProperty extends Command {exitWithError(exp.getMessage());}- System.out.println(property + " property removed.");+ printInformation(property + " property removed.");}@Overridediff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/SchemaAudit.java b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/SchemaAudit.javaindex ea891964da..17a0c31e45 100644--- a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/SchemaAudit.java+++ b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/SchemaAudit.java@@ -20,6 +20,7 @@package org.apache.gravitino.cli.commands;import org.apache.gravitino.Schema;+import org.apache.gravitino.cli.CommandContext;import org.apache.gravitino.cli.ErrorMessages;import org.apache.gravitino.client.GravitinoClient;import org.apache.gravitino.exceptions.NoSuchCatalogException;@@ -36,15 +37,13 @@ public class SchemaAudit extends AuditCommand {/*** Displays the audit information of a schema.*- * @param url The URL of the Gravitino server.- * @param ignoreVersions If true don't check the client/server versions match.+ * @param context The command context.* @param metalake The name of the metalake.* @param catalog The name of the catalog.* @param schema The name of the schenma.*/- public SchemaAudit(- String url, boolean ignoreVersions, String metalake, String catalog, String schema) {- super(url, ignoreVersions);+ public SchemaAudit(CommandContext context, String metalake, String catalog, String schema) {+ super(context);this.metalake = metalake;this.catalog = catalog;this.schema = schema;diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/SchemaDetails.java b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/SchemaDetails.javaindex 7369c0d1b4..b9c530aea5 100644--- a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/SchemaDetails.java+++ b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/SchemaDetails.java@@ -20,6 +20,7 @@package org.apache.gravitino.cli.commands;import org.apache.gravitino.Schema;+import org.apache.gravitino.cli.CommandContext;import org.apache.gravitino.cli.ErrorMessages;import org.apache.gravitino.client.GravitinoClient;import org.apache.gravitino.exceptions.NoSuchCatalogException;@@ -36,15 +37,13 @@ public class SchemaDetails extends Command {/*** Displays the details of a schema.*- * @param url The URL of the Gravitino server.- * @param ignoreVersions If true don't check the client/server versions match.+ * @param context The command context.* @param metalake The name of the metalake.* @param catalog The name of the catalog.* @param schema The name of the schenma.*/- public SchemaDetails(- String url, boolean ignoreVersions, String metalake, String catalog, String schema) {- super(url, ignoreVersions);+ public SchemaDetails(CommandContext context, String metalake, String catalog, String schema) {+ super(context);this.metalake = metalake;this.catalog = catalog;this.schema = schema;@@ -69,7 +68,7 @@ public class SchemaDetails extends Command {}if (result != null) {- System.out.println(result.name() + "," + result.comment());+ printInformation(result.name() + "," + result.comment());}}}diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/SetSchemaProperty.java b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/SetSchemaProperty.javaindex bd9851ba8c..854befc747 100644--- a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/SetSchemaProperty.java+++ b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/SetSchemaProperty.java@@ -20,6 +20,7 @@package org.apache.gravitino.cli.commands;import org.apache.gravitino.SchemaChange;+import org.apache.gravitino.cli.CommandContext;import org.apache.gravitino.cli.ErrorMessages;import org.apache.gravitino.client.GravitinoClient;import org.apache.gravitino.exceptions.NoSuchCatalogException;@@ -38,8 +39,7 @@ public class SetSchemaProperty extends Command {/*** Set a property of a schema.*- * @param url The URL of the Gravitino server.- * @param ignoreVersions If true don't check the client/server versions match.+ * @param context The command context.* @param metalake The name of the metalake.* @param catalog The name of the catalog.* @param schema The name of the schema.@@ -47,14 +47,13 @@ public class SetSchemaProperty extends Command {* @param value The value of the property.*/public SetSchemaProperty(- String url,- boolean ignoreVersions,+ CommandContext context,String metalake,String catalog,String schema,String property,String value) {- super(url, ignoreVersions);+ super(context);this.metalake = metalake;this.catalog = catalog;this.schema = schema;diff --git a/clients/cli/src/test/java/org/apache/gravitino/cli/TestSchemaCommands.java b/clients/cli/src/test/java/org/apache/gravitino/cli/TestSchemaCommands.javaindex 6b8770d8ed..12b3d72ba1 100644--- a/clients/cli/src/test/java/org/apache/gravitino/cli/TestSchemaCommands.java+++ b/clients/cli/src/test/java/org/apache/gravitino/cli/TestSchemaCommands.java@@ -22,6 +22,8 @@ package org.apache.gravitino.cli;import static org.junit.Assert.assertEquals;import static org.junit.Assert.assertThrows;import static org.junit.Assert.assertTrue;+import static org.mockito.ArgumentMatchers.any;+import static org.mockito.ArgumentMatchers.eq;import static org.mockito.Mockito.doReturn;import static org.mockito.Mockito.mock;import static org.mockito.Mockito.never;@@ -87,7 +89,7 @@ class TestSchemaCommands {mockCommandLine, mockOptions, CommandEntities.SCHEMA, CommandActions.LIST));doReturn(mockList).when(commandLine)- .newListSchema(GravitinoCommandLine.DEFAULT_URL, false, "metalake_demo", "catalog");+ .newListSchema(any(CommandContext.class), eq("metalake_demo"), eq("catalog"));doReturn(mockList).when(mockList).validate();commandLine.handleCommandLine();verify(mockList).handle();@@ -108,7 +110,7 @@ class TestSchemaCommands {doReturn(mockDetails).when(commandLine).newSchemaDetails(- GravitinoCommandLine.DEFAULT_URL, false, "metalake_demo", "catalog", "schema");+ any(CommandContext.class), eq("metalake_demo"), eq("catalog"), eq("schema"));doReturn(mockDetails).when(mockDetails).validate();commandLine.handleCommandLine();verify(mockDetails).handle();@@ -129,7 +131,7 @@ class TestSchemaCommands {doReturn(mockAudit).when(commandLine).newSchemaAudit(- GravitinoCommandLine.DEFAULT_URL, false, "metalake_demo", "catalog", "schema");+ any(CommandContext.class), eq("metalake_demo"), eq("catalog"), eq("schema"));doReturn(mockAudit).when(mockAudit).validate();commandLine.handleCommandLine();verify(mockAudit).handle();@@ -152,12 +154,11 @@ class TestSchemaCommands {doReturn(mockCreate).when(commandLine).newCreateSchema(- GravitinoCommandLine.DEFAULT_URL,- false,- "metalake_demo",- "catalog",- "schema",- "comment");+ any(CommandContext.class),+ eq("metalake_demo"),+ eq("catalog"),+ eq("schema"),+ eq("comment"));doReturn(mockCreate).when(mockCreate).validate();commandLine.handleCommandLine();verify(mockCreate).handle();@@ -177,7 +178,7 @@ class TestSchemaCommands {doReturn(mockDelete).when(commandLine).newDeleteSchema(- GravitinoCommandLine.DEFAULT_URL, false, false, "metalake_demo", "catalog", "schema");+ any(CommandContext.class), eq("metalake_demo"), eq("catalog"), eq("schema"));doReturn(mockDelete).when(mockDelete).validate();commandLine.handleCommandLine();verify(mockDelete).handle();@@ -198,7 +199,7 @@ class TestSchemaCommands {doReturn(mockDelete).when(commandLine).newDeleteSchema(- GravitinoCommandLine.DEFAULT_URL, false, true, "metalake_demo", "catalog", "schema");+ any(CommandContext.class), eq("metalake_demo"), eq("catalog"), eq("schema"));doReturn(mockDelete).when(mockDelete).validate();commandLine.handleCommandLine();verify(mockDelete).handle();@@ -222,13 +223,12 @@ class TestSchemaCommands {doReturn(mockSetProperty).when(commandLine).newSetSchemaProperty(- GravitinoCommandLine.DEFAULT_URL,- false,- "metalake_demo",- "catalog",- "schema",- "property",- "value");+ any(CommandContext.class),+ eq("metalake_demo"),+ eq("catalog"),+ eq("schema"),+ eq("property"),+ eq("value"));doReturn(mockSetProperty).when(mockSetProperty).validate();commandLine.handleCommandLine();verify(mockSetProperty).handle();@@ -237,16 +237,10 @@ class TestSchemaCommands {@Testvoid testSetSchemaPropertyCommandWithoutPropertyAndValue() {Main.useExit = false;+ CommandContext mockContext = mock(CommandContext.class);+ when(mockContext.url()).thenReturn(GravitinoCommandLine.DEFAULT_URL);SetSchemaProperty spySetProperty =- spy(- new SetSchemaProperty(- GravitinoCommandLine.DEFAULT_URL,- false,- "metalake_demo",- "catalog",- "schema",- null,- null));+ spy(new SetSchemaProperty(mockContext, "metalake_demo", "catalog", "schema", null, null));assertThrows(RuntimeException.class, spySetProperty::validate);verify(spySetProperty, never()).handle();@@ -257,16 +251,12 @@ class TestSchemaCommands {@Testvoid testSetSchemaPropertyCommandWithoutProperty() {Main.useExit = false;+ CommandContext mockContext = mock(CommandContext.class);+ when(mockContext.url()).thenReturn(GravitinoCommandLine.DEFAULT_URL);SetSchemaProperty spySetProperty =spy(new SetSchemaProperty(- GravitinoCommandLine.DEFAULT_URL,- false,- "metalake_demo",- "catalog",- "schema",- null,- "value"));+ mockContext, "metalake_demo", "catalog", "schema", null, "value"));assertThrows(RuntimeException.class, spySetProperty::validate);verify(spySetProperty, never()).handle();@@ -277,16 +267,12 @@ class TestSchemaCommands {@Testvoid testSetSchemaPropertyCommandWithoutValue() {Main.useExit = false;+ CommandContext mockContext = mock(CommandContext.class);+ when(mockContext.url()).thenReturn(GravitinoCommandLine.DEFAULT_URL);SetSchemaProperty spySetProperty =spy(new SetSchemaProperty(- GravitinoCommandLine.DEFAULT_URL,- false,- "metalake_demo",- "catalog",- "schema",- "property",- null));+ mockContext, "metalake_demo", "catalog", "schema", "property", null));assertThrows(RuntimeException.class, spySetProperty::validate);verify(spySetProperty, never()).handle();@@ -310,12 +296,12 @@ class TestSchemaCommands {doReturn(mockRemoveProperty).when(commandLine).newRemoveSchemaProperty(- GravitinoCommandLine.DEFAULT_URL,- false,- "metalake_demo",- "catalog",- "schema",- "property");+ any(CommandContext.class),+ eq("metalake_demo"),+ eq("catalog"),+ eq("schema"),+ eq("property"));+doReturn(mockRemoveProperty).when(mockRemoveProperty).validate();commandLine.handleCommandLine();verify(mockRemoveProperty).handle();@@ -324,15 +310,10 @@ class TestSchemaCommands {@Testvoid testRemoveSchemaPropertyCommandWithoutProperty() {Main.useExit = false;+ CommandContext mockContext = mock(CommandContext.class);+ when(mockContext.url()).thenReturn(GravitinoCommandLine.DEFAULT_URL);RemoveSchemaProperty mockRemoveProperty =- spy(- new RemoveSchemaProperty(- GravitinoCommandLine.DEFAULT_URL,- false,- "demo_metalake",- "catalog",- "schema",- null));+ spy(new RemoveSchemaProperty(mockContext, "demo_metalake", "catalog", "schema", null));assertThrows(RuntimeException.class, mockRemoveProperty::validate);String errOutput = new String(errContent.toByteArray(), StandardCharsets.UTF_8).trim();@@ -353,7 +334,7 @@ class TestSchemaCommands {doReturn(mockListProperties).when(commandLine).newListSchemaProperties(- GravitinoCommandLine.DEFAULT_URL, false, "metalake_demo", "catalog", "schema");+ any(CommandContext.class), eq("metalake_demo"), eq("catalog"), eq("schema"));doReturn(mockListProperties).when(mockListProperties).validate();commandLine.handleCommandLine();verify(mockListProperties).handle();@@ -374,7 +355,7 @@ class TestSchemaCommands {assertThrows(RuntimeException.class, commandLine::handleCommandLine);verify(commandLine, never())- .newListSchema(GravitinoCommandLine.DEFAULT_URL, false, "metalake_demo", null);+ .newListSchema(any(CommandContext.class), eq("metalake_demo"), eq(null));assertTrue(errContent.toString().contains(ErrorMessages.MISSING_ENTITIES + CommandEntities.CATALOG));}