apache/gravitino

[Improvement] Improve validation in SetModelVersionProperty.java

Open

#9,076 建立於 2025年11月11日

在 GitHub 查看
 (4 留言) (0 反應) (1 負責人)Java (887 fork)auto 404
good first issueimprovement

倉庫指標

Star
 (3,058 star)
PR 合併指標
 (PR 指標待抓取)

描述

What would you like to be improved?

Prevent the SetModelVersionProperty CLI command from accepting both an alias and version (or neither), ensuring it fails instead of invoking the server with invalid inputs. Include unit tests, for example:

  @Test
  void validateBothAliasAndVersion() {
    CommandLine mockCmdLine = Mockito.mock(CommandLine.class);
    CommandContext context = new CommandContext(mockCmdLine);

    SetModelVersionProperty command =
        new SetModelVersionProperty(
            context,
            "metalake1",
            "catalog1",
            "schema1",
            "model1",
            1,
            "alias1",
            "prop",
            "value");

   Assertions.assertThrows(RuntimeException.class, command::validate);
  }

How should we improve?

Improve validation and add unit tests, note you'll need to do this Main.useExit = false;.

貢獻者指南