0

I need to create custom assertion for list items.

For example, I have ArrayList in which there is an Address Object, now I need to create a custom assertion to check anySatisfy

Assertions.assertThat(results.result).anySatisfy(p->{
        assertThat(p.getAddress().getCity()).withFailMessage("expected city: "+ "Caseros1").isEqualTo("Caseros1");
        assertThat(p.getAddress().getCountryName()).isEqualTo("Argentina");
    });

Any suggestion. Thanks!

Andrei Sfat
  • 8,440
  • 5
  • 49
  • 69
Rejish R
  • 43
  • 1
  • 4
  • and what error do you get when you do this? – Andrei Sfat Feb 19 '19 at 15:20
  • I am looking to get individual error messages like "expected city not found" or "expected Country not found" but i get more generic error messages "Expecting any element of: to satisfy the given assertions requirements but none did." – Rejish R Feb 20 '19 at 05:13

1 Answers1

0

This issue, which was since some time already available on allSatisfy is now also available in release 3.12, see the respective issue.

So please upgrade to the latest AssertJ release and verify that this is working for you.

mle
  • 2,466
  • 1
  • 19
  • 25