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 3f976ef0b7bbbfda2ba2384e384d9bd48206c0d7..75dc1ec695d03ddf0b08a8b89240442e33bfc16b 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 0000000000000000000000000000000000000000..f8a31f51a54a548a9ea4ec8d9a49e7ebae9c3eec --- /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."); + } +}