Skip to content

Commit

Permalink
[apache#6235] improvement(authorizations): fix PathBasedMetadataObjec…
Browse files Browse the repository at this point in the history
…t.java toString method

fix toString method.
  • Loading branch information
Abyss-lord committed Jan 15, 2025
1 parent 39ad18a commit 03cd2f2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,13 @@ public int hashCode() {

@Override
public String toString() {
return "MetadataObject: [fullName=" + fullName() + "], [path=" + path == null
? "null"
: path + "], [type=" + type + "]";
String pathStr = path == null ? "null" : path;
return "MetadataObject: [fullName="
+ fullName()
+ "], [path="
+ pathStr
+ "], [type="
+ type
+ "]";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,31 @@ public void PathBasedMetadataObjectNotEquals() {

Assertions.assertNotEquals(pathBasedMetadataObject1, pathBasedMetadataObject2);
}

@Test
void testToString() {
PathBasedMetadataObject pathBasedMetadataObject1 =
new PathBasedMetadataObject("parent", "name", "path", PathBasedMetadataObject.Type.PATH);
Assertions.assertEquals(
"MetadataObject: [fullName=parent.name], [path=path], [type=PATH]",
pathBasedMetadataObject1.toString());

PathBasedMetadataObject pathBasedMetadataObject2 =
new PathBasedMetadataObject("parent", "name", null, PathBasedMetadataObject.Type.PATH);
Assertions.assertEquals(
"MetadataObject: [fullName=parent.name], [path=null], [type=PATH]",
pathBasedMetadataObject2.toString());

PathBasedMetadataObject pathBasedMetadataObject3 =
new PathBasedMetadataObject(null, "name", null, PathBasedMetadataObject.Type.PATH);
Assertions.assertEquals(
"MetadataObject: [fullName=name], [path=null], [type=PATH]",
pathBasedMetadataObject3.toString());

PathBasedMetadataObject pathBasedMetadataObject4 =
new PathBasedMetadataObject(null, "name", "path", PathBasedMetadataObject.Type.PATH);
Assertions.assertEquals(
"MetadataObject: [fullName=name], [path=path], [type=PATH]",
pathBasedMetadataObject4.toString());
}
}

0 comments on commit 03cd2f2

Please sign in to comment.