From ae3ed25af32687f51987242ef1b402e9db7dfa2e Mon Sep 17 00:00:00 2001 From: Holger Veltrup <92872893+sitepark-veltrup@users.noreply.github.com> Date: Thu, 2 Nov 2023 10:41:50 +0100 Subject: [PATCH] refactor: add Exception-suffix for exception-classes (#44) --- .../core/domain/entity/Anchor.java | 8 ++++---- .../core/domain/exception/AccessDenied.java | 14 -------------- .../exception/AccessDeniedException.java | 14 ++++++++++++++ ....java => AnchorAlreadyExistsException.java} | 4 ++-- ...Found.java => AnchorNotFoundException.java} | 4 ++-- ...yLocked.java => EntityLockedException.java} | 4 ++-- ...Found.java => EntityNotFoundException.java} | 4 ++-- ...tEmpty.java => GroupNotEmptyException.java} | 4 ++-- ...Anchor.java => InvalidAnchorException.java} | 4 ++-- ...issing.java => ParentMissingException.java} | 2 +- .../core/usecase/BulkPurge.java | 10 +++++----- .../core/usecase/PurgeEntity.java | 8 ++++---- .../core/usecase/RecoverEntity.java | 8 ++++---- .../core/usecase/RemoveEntity.java | 8 ++++---- .../core/usecase/StoreEntity.java | 18 +++++++++--------- .../core/usecase/PurgeEntityTest.java | 12 ++++++------ 16 files changed, 63 insertions(+), 63 deletions(-) delete mode 100644 src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AccessDenied.java create mode 100644 src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AccessDeniedException.java rename src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/{AnchorAlreadyExists.java => AnchorAlreadyExistsException.java} (78%) rename src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/{AnchorNotFound.java => AnchorNotFoundException.java} (77%) rename src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/{EntityLocked.java => EntityLockedException.java} (76%) rename src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/{EntityNotFound.java => EntityNotFoundException.java} (73%) rename src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/{GroupNotEmpty.java => GroupNotEmptyException.java} (73%) rename src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/{InvalidAnchor.java => InvalidAnchorException.java} (72%) rename src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/{ParentMissing.java => ParentMissingException.java} (61%) diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/Anchor.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/Anchor.java index fd5c5ee..5c16bd9 100644 --- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/Anchor.java +++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/Anchor.java @@ -6,7 +6,7 @@ import java.util.regex.Pattern; import com.fasterxml.jackson.annotation.JsonValue; -import com.sitepark.ies.contentrepository.core.domain.exception.InvalidAnchor; +import com.sitepark.ies.contentrepository.core.domain.exception.InvalidAnchorException; public final class Anchor implements Serializable { @@ -49,16 +49,16 @@ public String getName() { } /** - * @throws InvalidAnchor + * @throws InvalidAnchorException */ private static void validate(String name) { if (ONLY_NUMBERS_PATTERN.matcher(name).matches()) { - throw new InvalidAnchor(name, "Anchor must not only consist of numbers"); + throw new InvalidAnchorException(name, "Anchor must not only consist of numbers"); } if (!VALIDATOR_PATTERN.matcher(name).matches()) { - throw new InvalidAnchor(name, "Anchor contains Spaces"); + throw new InvalidAnchorException(name, "Anchor contains Spaces"); } } diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AccessDenied.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AccessDenied.java deleted file mode 100644 index d6c00eb..0000000 --- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AccessDenied.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.sitepark.ies.contentrepository.core.domain.exception; - -public class AccessDenied extends ContentRepositoryException { - private static final long serialVersionUID = 1L; - - public AccessDenied(String message) { - super(message); - } - - public AccessDenied(String message, Throwable t) { - super(message, t); - } - -} \ No newline at end of file diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AccessDeniedException.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AccessDeniedException.java new file mode 100644 index 0000000..eb8e60d --- /dev/null +++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AccessDeniedException.java @@ -0,0 +1,14 @@ +package com.sitepark.ies.contentrepository.core.domain.exception; + +public class AccessDeniedException extends ContentRepositoryException { + private static final long serialVersionUID = 1L; + + public AccessDeniedException(String message) { + super(message); + } + + public AccessDeniedException(String message, Throwable t) { + super(message, t); + } + +} \ No newline at end of file diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AnchorAlreadyExists.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AnchorAlreadyExistsException.java similarity index 78% rename from src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AnchorAlreadyExists.java rename to src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AnchorAlreadyExistsException.java index 5357b73..43ee728 100644 --- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AnchorAlreadyExists.java +++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AnchorAlreadyExistsException.java @@ -2,7 +2,7 @@ import com.sitepark.ies.contentrepository.core.domain.entity.Anchor; -public class AnchorAlreadyExists extends ContentRepositoryException { +public class AnchorAlreadyExistsException extends ContentRepositoryException { private static final long serialVersionUID = 1L; @@ -10,7 +10,7 @@ public class AnchorAlreadyExists extends ContentRepositoryException { private final long owner; - public AnchorAlreadyExists(Anchor anchor, long owner) { + public AnchorAlreadyExistsException(Anchor anchor, long owner) { super(); this.anchor = anchor; this.owner = owner; diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AnchorNotFound.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AnchorNotFoundException.java similarity index 77% rename from src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AnchorNotFound.java rename to src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AnchorNotFoundException.java index 2569e6f..86fa15e 100644 --- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AnchorNotFound.java +++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AnchorNotFoundException.java @@ -2,13 +2,13 @@ import com.sitepark.ies.contentrepository.core.domain.entity.Anchor; -public class AnchorNotFound extends ContentRepositoryException { +public class AnchorNotFoundException extends ContentRepositoryException { private static final long serialVersionUID = 1L; private final Anchor anchor; - public AnchorNotFound(Anchor anchor) { + public AnchorNotFoundException(Anchor anchor) { super(); this.anchor = anchor; } diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/EntityLocked.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/EntityLockedException.java similarity index 76% rename from src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/EntityLocked.java rename to src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/EntityLockedException.java index c0a2de6..c636302 100644 --- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/EntityLocked.java +++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/EntityLockedException.java @@ -2,13 +2,13 @@ import com.sitepark.ies.contentrepository.core.domain.entity.EntityLock; -public class EntityLocked extends ContentRepositoryException { +public class EntityLockedException extends ContentRepositoryException { private static final long serialVersionUID = 1L; private final EntityLock lock; - public EntityLocked(EntityLock lock) { + public EntityLockedException(EntityLock lock) { super(); this.lock = lock; } diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/EntityNotFound.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/EntityNotFoundException.java similarity index 73% rename from src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/EntityNotFound.java rename to src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/EntityNotFoundException.java index d2849d1..1bb1775 100644 --- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/EntityNotFound.java +++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/EntityNotFoundException.java @@ -1,12 +1,12 @@ package com.sitepark.ies.contentrepository.core.domain.exception; -public class EntityNotFound extends ContentRepositoryException { +public class EntityNotFoundException extends ContentRepositoryException { private static final long serialVersionUID = 1L; private final long id; - public EntityNotFound(long id) { + public EntityNotFoundException(long id) { super(); this.id = id; } diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/GroupNotEmpty.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/GroupNotEmptyException.java similarity index 73% rename from src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/GroupNotEmpty.java rename to src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/GroupNotEmptyException.java index 8c69839..790c577 100644 --- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/GroupNotEmpty.java +++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/GroupNotEmptyException.java @@ -1,11 +1,11 @@ package com.sitepark.ies.contentrepository.core.domain.exception; -public class GroupNotEmpty extends ContentRepositoryException { +public class GroupNotEmptyException extends ContentRepositoryException { private static final long serialVersionUID = 1L; private final long id; - public GroupNotEmpty(long id) { + public GroupNotEmptyException(long id) { super(); this.id = id; } diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/InvalidAnchor.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/InvalidAnchorException.java similarity index 72% rename from src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/InvalidAnchor.java rename to src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/InvalidAnchorException.java index 3e8104f..7fbeb3f 100644 --- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/InvalidAnchor.java +++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/InvalidAnchorException.java @@ -1,12 +1,12 @@ package com.sitepark.ies.contentrepository.core.domain.exception; -public class InvalidAnchor extends ContentRepositoryException { +public class InvalidAnchorException extends ContentRepositoryException { private final String name; private static final long serialVersionUID = 1L; - public InvalidAnchor(String name, String message) { + public InvalidAnchorException(String name, String message) { super(message); this.name = name; } diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/ParentMissing.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/ParentMissingException.java similarity index 61% rename from src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/ParentMissing.java rename to src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/ParentMissingException.java index fe36a09..4e66c28 100644 --- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/ParentMissing.java +++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/ParentMissingException.java @@ -1,5 +1,5 @@ package com.sitepark.ies.contentrepository.core.domain.exception; -public class ParentMissing extends ContentRepositoryException { +public class ParentMissingException extends ContentRepositoryException { private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/usecase/BulkPurge.java b/src/main/java/com/sitepark/ies/contentrepository/core/usecase/BulkPurge.java index 57bf834..85954a7 100644 --- a/src/main/java/com/sitepark/ies/contentrepository/core/usecase/BulkPurge.java +++ b/src/main/java/com/sitepark/ies/contentrepository/core/usecase/BulkPurge.java @@ -17,8 +17,8 @@ import com.sitepark.ies.contentrepository.core.domain.entity.EntityTree; import com.sitepark.ies.contentrepository.core.domain.entity.query.Query; import com.sitepark.ies.contentrepository.core.domain.entity.query.SubTreeQuery; -import com.sitepark.ies.contentrepository.core.domain.exception.AccessDenied; -import com.sitepark.ies.contentrepository.core.domain.exception.GroupNotEmpty; +import com.sitepark.ies.contentrepository.core.domain.exception.AccessDeniedException; +import com.sitepark.ies.contentrepository.core.domain.exception.GroupNotEmptyException; import com.sitepark.ies.contentrepository.core.port.AccessControl; import com.sitepark.ies.contentrepository.core.port.ContentRepository; import com.sitepark.ies.contentrepository.core.port.EntityBulkExecutor; @@ -129,11 +129,11 @@ private void accessControl(List entityList) { long id = entity.getId().get(); if (entity.isGroup()) { if (!this.accessControl.isGroupRemoveable(id)) { - throw new AccessDenied("Not allowed to remove group " + id); + throw new AccessDeniedException("Not allowed to remove group " + id); } } else { if (!this.accessControl.isEntityRemovable(id)) { - throw new AccessDenied("Not allowed to remove entity " + id); + throw new AccessDeniedException("Not allowed to remove entity " + id); } } }); @@ -203,7 +203,7 @@ private EntityBulkOperation buildPurgeOperation(List entityList) { long id = entity.getId().get(); if (this.repository.isGroup(id) && !this.repository.isEmptyGroup(id)) { - throw new GroupNotEmpty(id); + throw new GroupNotEmptyException(id); } if (LOGGER.isInfoEnabled()) { diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/usecase/PurgeEntity.java b/src/main/java/com/sitepark/ies/contentrepository/core/usecase/PurgeEntity.java index 9513d48..b131bd8 100644 --- a/src/main/java/com/sitepark/ies/contentrepository/core/usecase/PurgeEntity.java +++ b/src/main/java/com/sitepark/ies/contentrepository/core/usecase/PurgeEntity.java @@ -5,8 +5,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import com.sitepark.ies.contentrepository.core.domain.exception.AccessDenied; -import com.sitepark.ies.contentrepository.core.domain.exception.GroupNotEmpty; +import com.sitepark.ies.contentrepository.core.domain.exception.AccessDeniedException; +import com.sitepark.ies.contentrepository.core.domain.exception.GroupNotEmptyException; import com.sitepark.ies.contentrepository.core.port.AccessControl; import com.sitepark.ies.contentrepository.core.port.ContentRepository; import com.sitepark.ies.contentrepository.core.port.EntityLockManager; @@ -64,11 +64,11 @@ protected PurgeEntity(ContentRepository repository, EntityLockManager lockManage public void purgeEntity(long id) { if (!this.accessControl.isEntityRemovable(id)) { - throw new AccessDenied("Not allowed to remove entity " + id); + throw new AccessDeniedException("Not allowed to remove entity " + id); } if (this.repository.isGroup(id) && !this.repository.isEmptyGroup(id)) { - throw new GroupNotEmpty(id); + throw new GroupNotEmptyException(id); } try { diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/usecase/RecoverEntity.java b/src/main/java/com/sitepark/ies/contentrepository/core/usecase/RecoverEntity.java index 5de21c5..94077aa 100644 --- a/src/main/java/com/sitepark/ies/contentrepository/core/usecase/RecoverEntity.java +++ b/src/main/java/com/sitepark/ies/contentrepository/core/usecase/RecoverEntity.java @@ -5,8 +5,8 @@ import com.sitepark.ies.contentrepository.core.domain.entity.Entity; import com.sitepark.ies.contentrepository.core.domain.entity.HistoryEntryType; import com.sitepark.ies.contentrepository.core.domain.entity.RecycleBinItem; -import com.sitepark.ies.contentrepository.core.domain.exception.AccessDenied; -import com.sitepark.ies.contentrepository.core.domain.exception.EntityNotFound; +import com.sitepark.ies.contentrepository.core.domain.exception.AccessDeniedException; +import com.sitepark.ies.contentrepository.core.domain.exception.EntityNotFoundException; import com.sitepark.ies.contentrepository.core.port.AccessControl; import com.sitepark.ies.contentrepository.core.port.ContentRepository; import com.sitepark.ies.contentrepository.core.port.HistoryManager; @@ -33,10 +33,10 @@ protected RecoverEntity(ContentRepository repository, HistoryManager historyMana public void recover(long id) { Optional recycleBinItem = this.recycleBin.get(id); - recycleBinItem.orElseThrow(() -> new EntityNotFound(id)); + recycleBinItem.orElseThrow(() -> new EntityNotFoundException(id)); if (!this.accessControl.isGroupCreateable(recycleBinItem.get().getParent())) { - throw new AccessDenied("Not allowed to recover entity " + recycleBinItem.get().getId() + throw new AccessDeniedException("Not allowed to recover entity " + recycleBinItem.get().getId() + " in group " + recycleBinItem.get().getParent()); } diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/usecase/RemoveEntity.java b/src/main/java/com/sitepark/ies/contentrepository/core/usecase/RemoveEntity.java index f065d3b..4c3c263 100644 --- a/src/main/java/com/sitepark/ies/contentrepository/core/usecase/RemoveEntity.java +++ b/src/main/java/com/sitepark/ies/contentrepository/core/usecase/RemoveEntity.java @@ -6,8 +6,8 @@ import com.sitepark.ies.contentrepository.core.domain.entity.EntityLock; import com.sitepark.ies.contentrepository.core.domain.entity.HistoryEntryType; import com.sitepark.ies.contentrepository.core.domain.entity.RecycleBinItem; -import com.sitepark.ies.contentrepository.core.domain.exception.AccessDenied; -import com.sitepark.ies.contentrepository.core.domain.exception.EntityLocked; +import com.sitepark.ies.contentrepository.core.domain.exception.AccessDeniedException; +import com.sitepark.ies.contentrepository.core.domain.exception.EntityLockedException; import com.sitepark.ies.contentrepository.core.port.AccessControl; import com.sitepark.ies.contentrepository.core.port.ContentRepository; import com.sitepark.ies.contentrepository.core.port.EntityLockManager; @@ -42,7 +42,7 @@ protected RemoveEntity(ContentRepository repository, EntityLockManager lockManag public void remove(long id) { if (!this.accessControl.isEntityRemovable(id)) { - throw new AccessDenied("Not allowed to remove entity " + id); + throw new AccessDeniedException("Not allowed to remove entity " + id); } Optional entity = this.repository.get(id); @@ -53,7 +53,7 @@ public void remove(long id) { try { Optional lock = this.lockManager.getLock(id); lock.ifPresent(l -> { - throw new EntityLocked(l); + throw new EntityLockedException(l); }); this.searchIndex.remove(id); diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/usecase/StoreEntity.java b/src/main/java/com/sitepark/ies/contentrepository/core/usecase/StoreEntity.java index 51dfcc1..97de511 100644 --- a/src/main/java/com/sitepark/ies/contentrepository/core/usecase/StoreEntity.java +++ b/src/main/java/com/sitepark/ies/contentrepository/core/usecase/StoreEntity.java @@ -6,10 +6,10 @@ import com.sitepark.ies.contentrepository.core.domain.entity.Entity; import com.sitepark.ies.contentrepository.core.domain.entity.EntityLock; import com.sitepark.ies.contentrepository.core.domain.entity.HistoryEntryType; -import com.sitepark.ies.contentrepository.core.domain.exception.AccessDenied; -import com.sitepark.ies.contentrepository.core.domain.exception.EntityLocked; -import com.sitepark.ies.contentrepository.core.domain.exception.EntityNotFound; -import com.sitepark.ies.contentrepository.core.domain.exception.ParentMissing; +import com.sitepark.ies.contentrepository.core.domain.exception.AccessDeniedException; +import com.sitepark.ies.contentrepository.core.domain.exception.EntityLockedException; +import com.sitepark.ies.contentrepository.core.domain.exception.EntityNotFoundException; +import com.sitepark.ies.contentrepository.core.domain.exception.ParentMissingException; import com.sitepark.ies.contentrepository.core.domain.service.ContentDiffer; import com.sitepark.ies.contentrepository.core.port.AccessControl; import com.sitepark.ies.contentrepository.core.port.ContentRepository; @@ -54,12 +54,12 @@ public long store(Entity entity) { private long create(Entity newEntity) { Optional parent = newEntity.getParent(); - parent.orElseThrow(() -> new ParentMissing()); + parent.orElseThrow(() -> new ParentMissingException()); long parentId = parent.get(); if (!this.accessControl.isEntityCreateable(parentId)) { - throw new AccessDenied("Not allowed to create entity in group " + parent); + throw new AccessDeniedException("Not allowed to create entity in group " + parent); } long generatedId = this.idGenerator.generate(); @@ -84,16 +84,16 @@ private long update(Entity updateEntity) { long id = updateEntity.getId().get(); Optional existsEntity = this.repository.get(id); - existsEntity.orElseThrow(() -> new EntityNotFound(id)); + existsEntity.orElseThrow(() -> new EntityNotFoundException(id)); if (!this.accessControl.isEntityWritable(id)) { - throw new AccessDenied("Not allowed to update entity " + id); + throw new AccessDeniedException("Not allowed to update entity " + id); } try { Optional lock = this.lockManager.getLock(id); lock.ifPresent(l -> { - throw new EntityLocked(l); + throw new EntityLockedException(l); }); ChangeSet changeSet = this.contentDiffer.diff(updateEntity, existsEntity.get()); diff --git a/src/test/java/com/sitepark/ies/contentrepository/core/usecase/PurgeEntityTest.java b/src/test/java/com/sitepark/ies/contentrepository/core/usecase/PurgeEntityTest.java index 6e6f0f7..d489c1b 100644 --- a/src/test/java/com/sitepark/ies/contentrepository/core/usecase/PurgeEntityTest.java +++ b/src/test/java/com/sitepark/ies/contentrepository/core/usecase/PurgeEntityTest.java @@ -12,8 +12,8 @@ import org.mockito.InOrder; import com.sitepark.ies.contentrepository.core.domain.entity.EntityLock; -import com.sitepark.ies.contentrepository.core.domain.exception.AccessDenied; -import com.sitepark.ies.contentrepository.core.domain.exception.EntityLocked; +import com.sitepark.ies.contentrepository.core.domain.exception.AccessDeniedException; +import com.sitepark.ies.contentrepository.core.domain.exception.EntityLockedException; import com.sitepark.ies.contentrepository.core.port.AccessControl; import com.sitepark.ies.contentrepository.core.port.ContentRepository; import com.sitepark.ies.contentrepository.core.port.EntityLockManager; @@ -44,7 +44,7 @@ void testAccessDenied() { null, null, null); - assertThrows(AccessDenied.class, () -> { + assertThrows(AccessDeniedException.class, () -> { purgeEntity.purgeEntity(10L); }); } @@ -58,7 +58,7 @@ void testEntityIsLocked() { when(accessControl.isEntityRemovable(anyLong())).thenReturn(true); EntityLockManager lockManager = mock(EntityLockManager.class); - doThrow(new EntityLocked(EntityLock.builder().entity(10L).build())).when(lockManager).lock(anyLong()); + doThrow(new EntityLockedException(EntityLock.builder().entity(10L).build())).when(lockManager).lock(anyLong()); var purgeEntity = new PurgeEntity( repository, @@ -73,10 +73,10 @@ void testEntityIsLocked() { null); //purgeEntity.purgeEntity(10L); - EntityLocked entityLocked = assertThrows(EntityLocked.class, () -> { + EntityLockedException entityLockedException = assertThrows(EntityLockedException.class, () -> { purgeEntity.purgeEntity(10L); }, "entity should be locked"); - assertEquals(10L, entityLocked.getLock().getEntity(), "unexpected entity id"); + assertEquals(10L, entityLockedException.getLock().getEntity(), "unexpected entity id"); } @SuppressWarnings("PMD")