Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assertj extract and contains doesn't match

Tags:

assertj

I made a simple test :

Person p = new Person();
p.setFirstName("Stéphane");
p.setLastName("Traumat");

assertThat(p)
.extracting("firstName", "lastName")
.contains(tuple("Stéphane", "Traumat"));

And I get a strange result :

java.lang.AssertionError: 
Expecting:
<["Stéphane", "Traumat"]>
to contain:
<[("Stéphane", "Traumat")]>
but could not find:
<[("Stéphane", "Traumat")]>

Anyone can help me ?

like image 720
Stéphane Traumat Avatar asked Sep 02 '25 13:09

Stéphane Traumat


1 Answers

Don't use a tuple, the result of extracting in your case is a simple array, please also have a look at the javadoc for extracting, it contains an example showing how to use it.

like image 77
Joel Costigliola Avatar answered Sep 05 '25 15:09

Joel Costigliola