List<Human> list =newArrayList<>();list.add(newHuman("faker",26));list.add(newHuman("bang",26));list.add(newHuman("wolf",26));list.add(newHuman("keria",20));assertThat(list).filteredOn("age",not(26)).containsOnly(list.get(3));
@Testvoidextracting() {List<T1> members =newArrayList<>();members.add(newT1("faker",26));members.add(newT1("bang",26));members.add(newT1("wolf",26));members.add(newT1("keria",20));assertThat(members).extracting("name").contains("faker","bang","wolf","keria");assertThat(members).extracting("name","age").contains(tuple("faker",26),tuple("bang",26),tuple("wolf",26),tuple("keria",20)); }
@Testvoidtest() {String str ="test";SoftAssertions.assertSoftly(softAssertions -> {softAssertions.assertThat(StringUtils.hasText(str)).as("check '%s' is not null", str).isFalse();softAssertions.assertThat(StringUtils.hasLength(str)).as("check '%s' is not null", str).isTrue(); }); }
Multiple Failures (1 failure)
-- failure 1 --
[check 'test' is not null]
Expecting value to be false but was true
at SoftAssertionTest.lambda$test$0(SoftAssertionTest.java:15)
org.assertj.core.error.AssertJMultipleFailuresError:
Multiple Failures (1 failure)
-- failure 1 --