From 4f78b07490d008e6fdfaf78d480b9f61567c4680 Mon Sep 17 00:00:00 2001 From: Anyul Rivas Date: Thu, 14 Mar 2024 09:18:19 +0100 Subject: [PATCH] test: rewrite assertion using AssertJ for consistency --- .../petclinic/system/CrashControllerTests.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) 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 65d3b8921..4361b866b 100644 --- a/src/test/java/org/springframework/samples/petclinic/system/CrashControllerTests.java +++ b/src/test/java/org/springframework/samples/petclinic/system/CrashControllerTests.java @@ -16,7 +16,7 @@ package org.springframework.samples.petclinic.system; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; import org.junit.jupiter.api.Test; @@ -34,13 +34,11 @@ class CrashControllerTests { CrashController testee = new CrashController(); @Test - void testTriggerException() throws Exception { - RuntimeException thrown = assertThrows(RuntimeException.class, () -> { - testee.triggerException(); - }); + void testTriggerException() { + RuntimeException thrown = assertThrows(RuntimeException.class, () -> testee.triggerException()); - assertEquals("Expected: controller used to showcase what happens when an exception is thrown", - thrown.getMessage()); + assertThat(thrown.getMessage()) + .isEqualTo("Expected: controller used to showcase what happens when an exception is thrown"); } }