Venkata Rama Raju
Venkata Rama Raju

Reputation: 1345

How to check list of objects one property value count using AssertJ?

class Test{
private Boolean isChange;

}
Assume that tests list contains 1000 objets.

List<Test> tests = new ArrayList<Test>();
Test t  = new Test();
t.setIschange(true);
tests.add(t);

like that I have added 200 objects as true i.e isChanges value, remaining all are false out of 1000; and it will change to 300 like.

so how to check wheather list contains 200 objects isChange value is true using assertJ

Upvotes: 1

Views: 1641

Answers (1)

Joel Costigliola
Joel Costigliola

Reputation: 7126

You can use filter if you have a proper getter to access the value, or use a lambda:

assertThat(tests).filteredOn("change", true).hasSize(200);

Upvotes: 3

Related Questions