use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class IterableAssert_hasOnlyOneElementSatisfying_Test method succeeds_if_iterable_has_only_one_element_and_that_element_statisfies_the_given_assertions.
@Test
public void succeeds_if_iterable_has_only_one_element_and_that_element_statisfies_the_given_assertions() {
assertThat(asList(new Jedi("Yoda", "red"))).hasOnlyOneElementSatisfying(yoda -> {
assertThat(yoda.getName()).isEqualTo("Yoda");
assertThat(yoda.lightSaberColor).isEqualTo("red");
});
}
use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class IterableAssert_hasOnlyOneElementSatisfying_Test method fails_if_iterable_has_only_one_element_and_that_element_does_not_statisfy_the_soft_assertion.
@Test
public void fails_if_iterable_has_only_one_element_and_that_element_does_not_statisfy_the_soft_assertion() {
List<Jedi> jedis = asList(new Jedi("Yoda", "red"));
Throwable assertionError = catchThrowable(() -> {
assertThat(jedis).hasOnlyOneElementSatisfying(yoda -> {
SoftAssertions softly = new SoftAssertions();
softly.assertThat(yoda.getName()).startsWith("L");
softly.assertThat(yoda.getName()).startsWith("M");
softly.assertAll();
});
});
assertThat(assertionError).hasMessageContaining(format("Expecting:%n <\"Yoda\">%nto start with:%n <\"L\">")).hasMessageContaining(format("Expecting:%n <\"Yoda\">%nto start with:%n <\"M\">"));
}
use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class IterableAssert_hasOnlyOneElementSatisfying_Test method fails_if_iterable_has_more_than_one_element.
@Test
public void fails_if_iterable_has_more_than_one_element() {
thrown.expectAssertionErrorWithMessageContaining("Expected size:<1> but was:<2>");
List<Jedi> jedis = asList(new Jedi("Yoda", "red"), new Jedi("Luke", "green"));
assertThat(jedis).hasOnlyOneElementSatisfying(yoda -> assertThat(yoda.getName()).startsWith("Y"));
}
use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class IterableAssert_hasOnlyOneElementSatisfying_Test method fails_if_iterable_has_only_one_element_and_that_element_does_not_statisfy_one_of_the_given_assertion.
@Test
public void fails_if_iterable_has_only_one_element_and_that_element_does_not_statisfy_one_of_the_given_assertion() {
thrown.expectAssertionError("%nExpecting:%n <\"Yoda\">%nto start with:%n <\"L\">%n");
List<Jedi> jedis = asList(new Jedi("Yoda", "red"));
assertThat(jedis).hasOnlyOneElementSatisfying(yoda -> {
assertThat(yoda.getName()).startsWith("Y");
assertThat(yoda.getName()).startsWith("L");
});
}
use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class AbstractAssert_satisfies_Test method setup.
@Before
public void setup() {
yoda = new Jedi("Yoda", "Green");
luke = new Jedi("Luke Skywalker", "Green");
jediRequirements = jedi -> {
assertThat(jedi.lightSaberColor).as("check light saber").isEqualTo("Green");
assertThat(jedi.getName()).as("check name").doesNotContain("Dark");
};
}
Aggregations