Skip to content

Commit

Permalink
fix: Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveGT96 committed Nov 5, 2024
1 parent 12ca092 commit dc324ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/java/org/isf/menu/manager/UserBrowsingManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ public void deleteGroup(UserGroup aGroup) throws OHServiceException {
throw new OHDataValidationException(new OHExceptionMessage(MessageBundle.getMessage("angal.groupsbrowser.theadmingroupcannotbedeleted.msg")));
}
List<User> users = getUser(aGroup.getCode());
if (users != null && users.stream().anyMatch(user -> !user.isDeleted())) {
throw new OHDataValidationException(
if (users != null && !users.isEmpty()) {
throw new OHDataIntegrityViolationException(
new OHExceptionMessage(MessageBundle.getMessage("angal.groupsbrowser.thisgrouphasusersandcannotbedeleted.msg")));
}
ioOperations.deleteGroup(aGroup);
Expand Down Expand Up @@ -324,6 +324,13 @@ public UserGroup newUserGroup(UserGroup userGroup, List<Permission> permissions)
* @return {@code true} if the group has been updated, {@code false} otherwise.
*/
public boolean updateUserGroup(UserGroup userGroup) throws OHServiceException {
if (userGroup.isDeleted()) {
List<User> users = getUser(userGroup.getCode());
if (users != null && users.stream().anyMatch(User::isDeleted)) {
throw new OHDataValidationException(
new OHExceptionMessage(MessageBundle.getMessage("angal.groupsbrowser.thisgrouphasusersandcannotbedeleted.msg")));
}
}
return ioOperations.updateUserGroup(userGroup);
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/isf/menu/service/MenuIoOperations.java
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ public UserGroup newUserGroup(UserGroup userGroup, List<Permission> permissions)
*/
public boolean updateUserGroup(UserGroup aGroup) throws OHServiceException {
ensureUserGroupNotDeleted(aGroup.getCode());

return groupRepository.update(aGroup.getDesc(), aGroup.isDeleted(), aGroup.getCode()) > 0;
}

Expand Down

0 comments on commit dc324ad

Please sign in to comment.