Skip to content

Commit

Permalink
test: refactor using AssertJ assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
anyulled authored and dsyer committed May 16, 2024
1 parent c5b3b35 commit 7055f0c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ public boolean matches(Object item) {
@SuppressWarnings("unchecked")
List<Pet> pets = (List<Pet>) item;
Pet pet = pets.get(0);
return !pet.getVisits().isEmpty();
}
return !pet.getVisits().isEmpty();
}

@Override
public void describeTo(Description description) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
}

}

0 comments on commit 7055f0c

Please sign in to comment.