apache / apache/gravitino

[Improvement] Improve validation in SetModelVersionProperty.java

Open
#9,076 4 comments 0 reactions 1 assignee Claimed by @NazaninAnsarii View on GitHub
good first issue improvement
Dominant language
Java
Stars
3.2k
Forks
935
Avg merge
1d 16h
Merged PRs (30d)
298

Description

### 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;`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.