justinmclean opened a new issue, #8201:
URL: https://github.com/apache/gravitino/issues/8201
### What would you like to be improved?
The early return in GroupMetaService.java updateGroup mean changes such as
renames or audit info changes are ignored.
Here's a unit test to help:
```
@Test
void updateGroupWithoutRoleChange() throws IOException {
AuditInfo auditInfo =
AuditInfo.builder().withCreator("creator").withCreateTime(Instant.now()).build();
BaseMetalake metalake =
createBaseMakeLake(RandomIdGenerator.INSTANCE.nextId(),
metalakeName, auditInfo);
backend.insert(metalake, false);
GroupMetaService groupMetaService = GroupMetaService.getInstance();
GroupEntity group1 =
createGroupEntity(
RandomIdGenerator.INSTANCE.nextId(),
AuthorizationUtils.ofGroupNamespace(metalakeName),
"group1",
auditInfo);
groupMetaService.insertGroup(group1, false);
Function<GroupEntity, GroupEntity> renameUpdater =
group ->
GroupEntity.builder()
.withNamespace(group.namespace())
.withId(group.id())
.withName("group_renamed")
.withRoleNames(group.roleNames())
.withRoleIds(group.roleIds())
.withAuditInfo(group.auditInfo())
.build();
groupMetaService.updateGroup(group1.nameIdentifier(), renameUpdater);
Assertions.assertThrows(
NoSuchEntityException.class,
() ->
groupMetaService.getGroupByIdentifier(group1.nameIdentifier()));
GroupEntity updated =
groupMetaService.getGroupByIdentifier(
AuthorizationUtils.ofGroup(metalakeName, "group_renamed"));
Assertions.assertEquals("group_renamed", updated.name());
}
```
### How should we improve?
Remove the early return.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]