How can I assert hasProperty with a Java Record?
11
3
I have a piece of code in a test that checks that a list of results contains certain properties, using Hamcrest 2.2: assertThat(result.getUsers(), hasItem( hasProperty("name", equalTo(user1.getName())) )); assertThat(result.getUsers(), hasItem( hasProperty("name", equalTo(user2.getName())) )); This worked perfectly fine when NameDto was a normal class. But after I changed it to a Record , Hamcrest's hasProperty complains about there being no property named name : java.lang.AssertionError: Expected: a collection containing hasProperty("name", "Test Name") but: mismatches were: [No property "name", No property "name"] Is there some other matcher I can use to achieve the same matching a...