Skip to content

Commit

Permalink
[Minor] Remove unneeded eq's from tests (apache#6241)
Browse files Browse the repository at this point in the history
### What changes were proposed in this pull request?

No need for these eq's.

### Why are the changes needed?

As above

Fix: #N/A

### Does this PR introduce _any_ user-facing change?

No

### How was this patch tested?

Run locally, test passed.

Co-authored-by: Shaofeng Shi <[email protected]>
  • Loading branch information
justinmclean and shaofengshi authored Jan 21, 2025
1 parent 52db315 commit e56536b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,7 @@ void testListModelCommand() {
doReturn(mockList)
.when(commandLine)
.newListModel(
eq(GravitinoCommandLine.DEFAULT_URL),
eq(false),
eq("metalake_demo"),
eq("catalog"),
eq("schema"));
GravitinoCommandLine.DEFAULT_URL, false, "metalake_demo", "catalog", "schema");
doReturn(mockList).when(mockList).validate();
commandLine.handleCommandLine();
verify(mockList).handle();
Expand All @@ -112,12 +108,7 @@ void testListModelCommandWithoutCatalog() {

assertThrows(RuntimeException.class, commandLine::handleCommandLine);
verify(commandLine, never())
.newListModel(
eq(GravitinoCommandLine.DEFAULT_URL),
eq(false),
eq("metalake_demo"),
isNull(),
isNull());
.newListModel(GravitinoCommandLine.DEFAULT_URL, false, "metalake_demo", null, null);
String output = new String(errContent.toByteArray(), StandardCharsets.UTF_8).trim();
assertEquals(
ErrorMessages.MISSING_NAME
Expand All @@ -141,12 +132,7 @@ void testListModelCommandWithoutSchema() {

assertThrows(RuntimeException.class, commandLine::handleCommandLine);
verify(commandLine, never())
.newListModel(
eq(GravitinoCommandLine.DEFAULT_URL),
eq(false),
eq("metalake_demo"),
eq("catalog"),
isNull());
.newListModel(GravitinoCommandLine.DEFAULT_URL, false, "metalake_demo", "catalog", null);
String output = new String(errContent.toByteArray(), StandardCharsets.UTF_8).trim();
assertEquals(
ErrorMessages.MALFORMED_NAME
Expand All @@ -171,12 +157,7 @@ void testModelDetailsCommand() {
doReturn(mockList)
.when(commandLine)
.newModelDetails(
eq(GravitinoCommandLine.DEFAULT_URL),
eq(false),
eq("metalake_demo"),
eq("catalog"),
eq("schema"),
eq("model"));
GravitinoCommandLine.DEFAULT_URL, false, "metalake_demo", "catalog", "schema", "model");
doReturn(mockList).when(mockList).validate();
commandLine.handleCommandLine();
verify(mockList).handle();
Expand All @@ -197,12 +178,7 @@ void testModelDetailsCommandWithoutCatalog() {

verify(commandLine, never())
.newModelDetails(
eq(GravitinoCommandLine.DEFAULT_URL),
eq(false),
eq("metalake_demo"),
isNull(),
isNull(),
isNull());
GravitinoCommandLine.DEFAULT_URL, false, "metalake_demo", null, null, null);
String output = new String(errContent.toByteArray(), StandardCharsets.UTF_8).trim();
assertEquals(
ErrorMessages.MISSING_NAME
Expand Down Expand Up @@ -230,12 +206,7 @@ void testModelDetailsCommandWithoutSchema() {

verify(commandLine, never())
.newModelDetails(
eq(GravitinoCommandLine.DEFAULT_URL),
eq(false),
eq("metalake_demo"),
eq("catalog"),
isNull(),
isNull());
GravitinoCommandLine.DEFAULT_URL, false, "metalake_demo", "catalog", null, null);
String output = new String(errContent.toByteArray(), StandardCharsets.UTF_8).trim();
assertEquals(
ErrorMessages.MALFORMED_NAME
Expand All @@ -261,12 +232,7 @@ void testModelDetailsCommandWithoutModel() {

verify(commandLine, never())
.newModelDetails(
eq(GravitinoCommandLine.DEFAULT_URL),
eq(false),
eq("metalake_demo"),
eq("catalog"),
eq("schema"),
isNull());
GravitinoCommandLine.DEFAULT_URL, false, "metalake_demo", "catalog", "schema", null);
String output = new String(errContent.toByteArray(), StandardCharsets.UTF_8).trim();
assertEquals(
ErrorMessages.MALFORMED_NAME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
Expand Down Expand Up @@ -160,11 +158,11 @@ void testOwnerDetailsCommandWithoutName() {
assertThrows(RuntimeException.class, commandLine::handleCommandLine);
verify(commandLine, never())
.newOwnerDetails(
eq(GravitinoCommandLine.DEFAULT_URL),
eq(false),
eq("metalake_demo"),
eq(null),
eq(CommandEntities.CATALOG));
GravitinoCommandLine.DEFAULT_URL,
false,
"metalake_demo",
null,
CommandEntities.CATALOG);

String errOutput = new String(errContent.toByteArray(), StandardCharsets.UTF_8).trim();
assertEquals(ErrorMessages.MISSING_NAME, errOutput);
Expand All @@ -188,13 +186,13 @@ void testSetOwnerUserCommandWithoutUserAndGroup() {
assertThrows(RuntimeException.class, commandLine::handleCommandLine);
verify(commandLine, never())
.newSetOwner(
eq(GravitinoCommandLine.DEFAULT_URL),
eq(false),
eq("metalake_demo"),
eq("postgres"),
eq(CommandEntities.CATALOG),
isNull(),
eq(false));
GravitinoCommandLine.DEFAULT_URL,
false,
"metalake_demo",
"postgres",
CommandEntities.CATALOG,
null,
false);
String errOutput = new String(errContent.toByteArray(), StandardCharsets.UTF_8).trim();
assertEquals(ErrorMessages.INVALID_SET_COMMAND, errOutput);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ void testCreateRolesCommand() {
doReturn(mockCreate)
.when(commandLine)
.newCreateRole(
eq(GravitinoCommandLine.DEFAULT_URL),
eq(false),
eq("metalake_demo"),
eq(new String[] {"admin", "engineer", "scientist"}));
GravitinoCommandLine.DEFAULT_URL,
false,
"metalake_demo",
new String[] {"admin", "engineer", "scientist"});
doReturn(mockCreate).when(mockCreate).validate();
commandLine.handleCommandLine();
verify(mockCreate).handle();
Expand Down Expand Up @@ -235,11 +235,11 @@ void testDeleteRolesCommand() {
doReturn(mockDelete)
.when(commandLine)
.newDeleteRole(
eq(GravitinoCommandLine.DEFAULT_URL),
eq(false),
eq(false),
eq("metalake_demo"),
eq(new String[] {"admin", "engineer", "scientist"}));
GravitinoCommandLine.DEFAULT_URL,
false,
false,
"metalake_demo",
new String[] {"admin", "engineer", "scientist"});
doReturn(mockDelete).when(mockDelete).validate();
commandLine.handleCommandLine();
verify(mockDelete).handle();
Expand Down

0 comments on commit e56536b

Please sign in to comment.