From dc324ada668b568bb7c44019745de65d9378cf3e Mon Sep 17 00:00:00 2001 From: SteveGT96 Date: Tue, 5 Nov 2024 10:47:31 +0100 Subject: [PATCH] fix: Fix tests --- .../org/isf/menu/manager/UserBrowsingManager.java | 11 +++++++++-- .../java/org/isf/menu/service/MenuIoOperations.java | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/isf/menu/manager/UserBrowsingManager.java b/src/main/java/org/isf/menu/manager/UserBrowsingManager.java index 4a8405e7a..7cb3e3650 100644 --- a/src/main/java/org/isf/menu/manager/UserBrowsingManager.java +++ b/src/main/java/org/isf/menu/manager/UserBrowsingManager.java @@ -280,8 +280,8 @@ public void deleteGroup(UserGroup aGroup) throws OHServiceException { throw new OHDataValidationException(new OHExceptionMessage(MessageBundle.getMessage("angal.groupsbrowser.theadmingroupcannotbedeleted.msg"))); } List 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); @@ -324,6 +324,13 @@ public UserGroup newUserGroup(UserGroup userGroup, List permissions) * @return {@code true} if the group has been updated, {@code false} otherwise. */ public boolean updateUserGroup(UserGroup userGroup) throws OHServiceException { + if (userGroup.isDeleted()) { + List 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); } diff --git a/src/main/java/org/isf/menu/service/MenuIoOperations.java b/src/main/java/org/isf/menu/service/MenuIoOperations.java index d0b5e1337..defcc6364 100644 --- a/src/main/java/org/isf/menu/service/MenuIoOperations.java +++ b/src/main/java/org/isf/menu/service/MenuIoOperations.java @@ -353,6 +353,7 @@ public UserGroup newUserGroup(UserGroup userGroup, List permissions) */ public boolean updateUserGroup(UserGroup aGroup) throws OHServiceException { ensureUserGroupNotDeleted(aGroup.getCode()); + return groupRepository.update(aGroup.getDesc(), aGroup.isDeleted(), aGroup.getCode()) > 0; }