I have a class with some fields:
class User {
String name;
String id;
// other fields
}
I'm getting a user from the service and want to assert that name
and id
fields are not empty. The object contains other fields, but those are not needed for this particular case. I tried to extract required fields and apply the allSatisfy {}
function:
User user = service.getUser();
assertThat(user)
.extracting("name", "id") // extract only those fields that I need for now
.allSatisy { field -> assertThat(field).isNotEmpty() } // this doesn't compile because `field` is not a String
Am I using the extracting()
function wrong?
Or is there other way of asserting multiple fields of an object at once instead of asserting each field separately?