From 931d8f55b4c9eaf5c992bc4645531d687a8efee7 Mon Sep 17 00:00:00 2001 From: OZGCloud <ozgcloud@mgm-tp.com> Date: Wed, 6 Nov 2024 12:35:23 +0100 Subject: [PATCH] adjust not foun exception message --- .../errorhandling/NotFoundException.java | 2 +- .../errorhandling/NotFoundExceptionTest.java | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 api-lib-core/src/test/java/de/ozgcloud/apilib/common/errorhandling/NotFoundExceptionTest.java diff --git a/api-lib-core/src/main/java/de/ozgcloud/apilib/common/errorhandling/NotFoundException.java b/api-lib-core/src/main/java/de/ozgcloud/apilib/common/errorhandling/NotFoundException.java index 3f976ef..75dc1ec 100644 --- a/api-lib-core/src/main/java/de/ozgcloud/apilib/common/errorhandling/NotFoundException.java +++ b/api-lib-core/src/main/java/de/ozgcloud/apilib/common/errorhandling/NotFoundException.java @@ -7,6 +7,6 @@ public class NotFoundException extends RuntimeException { private static final String MESSAGE_TEMPL = "%s with id '%s' not found."; public NotFoundException(StringBasedValue id, String entityName) { - super(MESSAGE_TEMPL.formatted(id.toString(), entityName)); + super(MESSAGE_TEMPL.formatted(entityName, id.toString())); } } diff --git a/api-lib-core/src/test/java/de/ozgcloud/apilib/common/errorhandling/NotFoundExceptionTest.java b/api-lib-core/src/test/java/de/ozgcloud/apilib/common/errorhandling/NotFoundExceptionTest.java new file mode 100644 index 0000000..f8a31f5 --- /dev/null +++ b/api-lib-core/src/test/java/de/ozgcloud/apilib/common/errorhandling/NotFoundExceptionTest.java @@ -0,0 +1,20 @@ +package de.ozgcloud.apilib.common.errorhandling; + +import static org.assertj.core.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +import de.ozgcloud.apilib.common.datatypes.GenericId; + +class NotFoundExceptionTest { + + private final GenericId id = GenericId.from("dummyId"); + private final String entityName = "DummyEntity"; + + @Test + void shouldHaveMessage() { + var exception = new NotFoundException(id, entityName); + + assertThat(exception.getMessage()).isEqualTo(entityName + " with id '" + id + "' not found."); + } +} -- GitLab