mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-04-24 19:32:48 +00:00
test: refactor using AssertJ assertions
This commit is contained in:
parent
c5b3b3597e
commit
7055f0c6a6
2 changed files with 6 additions and 6 deletions
|
@ -231,8 +231,8 @@ class OwnerControllerTests {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<Pet> pets = (List<Pet>) item;
|
List<Pet> pets = (List<Pet>) item;
|
||||||
Pet pet = pets.get(0);
|
Pet pet = pets.get(0);
|
||||||
return !pet.getVisits().isEmpty();
|
return !pet.getVisits().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void describeTo(Description description) {
|
public void describeTo(Description description) {
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package org.springframework.samples.petclinic.system;
|
package org.springframework.samples.petclinic.system;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
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 static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
@ -35,10 +36,9 @@ class CrashControllerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testTriggerException() {
|
void testTriggerException() {
|
||||||
RuntimeException thrown = assertThrows(RuntimeException.class, () -> testee.triggerException());
|
assertThatExceptionOfType(RuntimeException.class)
|
||||||
|
.isThrownBy(()->testee.triggerException())
|
||||||
assertThat(thrown.getMessage())
|
.withMessageContaining("Expected: controller used to showcase what happens when an exception is thrown");
|
||||||
.isEqualTo("Expected: controller used to showcase what happens when an exception is thrown");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue