diff --git a/src/test/java/org/springframework/samples/petclinic/owner/OwnerControllerTests.java b/src/test/java/org/springframework/samples/petclinic/owner/OwnerControllerTests.java index 5d7c0cfce..a4ae657fe 100644 --- a/src/test/java/org/springframework/samples/petclinic/owner/OwnerControllerTests.java +++ b/src/test/java/org/springframework/samples/petclinic/owner/OwnerControllerTests.java @@ -231,8 +231,8 @@ class OwnerControllerTests { @SuppressWarnings("unchecked") List pets = (List) item; Pet pet = pets.get(0); - return !pet.getVisits().isEmpty(); - } + return !pet.getVisits().isEmpty(); + } @Override public void describeTo(Description description) { diff --git a/src/test/java/org/springframework/samples/petclinic/system/CrashControllerTests.java b/src/test/java/org/springframework/samples/petclinic/system/CrashControllerTests.java index 4361b866b..108983e9e 100644 --- a/src/test/java/org/springframework/samples/petclinic/system/CrashControllerTests.java +++ b/src/test/java/org/springframework/samples/petclinic/system/CrashControllerTests.java @@ -17,6 +17,7 @@ package org.springframework.samples.petclinic.system; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.junit.jupiter.api.Assertions.assertThrows; import org.junit.jupiter.api.Test; @@ -35,10 +36,9 @@ class CrashControllerTests { @Test void testTriggerException() { - RuntimeException thrown = assertThrows(RuntimeException.class, () -> testee.triggerException()); - - assertThat(thrown.getMessage()) - .isEqualTo("Expected: controller used to showcase what happens when an exception is thrown"); + assertThatExceptionOfType(RuntimeException.class) + .isThrownBy(()->testee.triggerException()) + .withMessageContaining("Expected: controller used to showcase what happens when an exception is thrown"); } }