test: rewrite assertion using AssertJ for consistency

This commit is contained in:
Anyul Rivas 2024-03-14 09:18:19 +01:00
parent a108f6c21b
commit 6a3d4aab57

View file

@ -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");
}
}