We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the bug I have the following simple assertion in my test:
hasProperty("name")
For the following record:
public record AnyDto( Long id, @NotBlank String name, String description) { }
And even though I can see the object does have the property (set with a value), the test fails.
I have tracked this down, and it seems the "issue" is generated in the PropertyUtil class, in the propertyDescriptorsFor method:
PropertyUtil
propertyDescriptorsFor
JavaHamcrest/hamcrest/src/main/java/org/hamcrest/beans/PropertyUtil.java
Line 49 in 5d76642
This is what Introspector.getBeanInfo(fromObj.getClass(), stopClass) retrieves for a Record class:
Introspector.getBeanInfo(fromObj.getClass(), stopClass)
If I change the AnyDto to a regular class, the test passes, because the Introspector method above does contain PropertyDescriptors for the class:
AnyDto
PropertyDescriptors
Note: the Record does contain name as a MethodDescriptor, maybe we can rely on these for the Records?
name
MethodDescriptor
This is a related Stackoverflow Question: https://stackoverflow.com/questions/66982522/how-can-i-assert-hasproperty-with-a-java-record
The text was updated successfully, but these errors were encountered:
It would be nice if property descriptors would be supplemented with Class::getRecordComponents in the case that Class::isRecord is true
Class::getRecordComponents
Class::isRecord
Sorry, something went wrong.
Improves score controller testing
47ebca9
Test still failing because I'm using Java record and hamcrest/JavaHamcrest#392
No branches or pull requests
Describe the bug
I have the following simple assertion in my test:
For the following record:
And even though I can see the object does have the property (set with a value), the test fails.
I have tracked this down, and it seems the "issue" is generated in the
PropertyUtil
class, in thepropertyDescriptorsFor
method:JavaHamcrest/hamcrest/src/main/java/org/hamcrest/beans/PropertyUtil.java
Line 49 in 5d76642
This is what
Introspector.getBeanInfo(fromObj.getClass(), stopClass)
retrieves for a Record class:If I change the
AnyDto
to a regular class, the test passes, because the Introspector method above does containPropertyDescriptors
for the class:Note: the Record does contain
name
as aMethodDescriptor
, maybe we can rely on these for the Records?This is a related Stackoverflow Question:
https://stackoverflow.com/questions/66982522/how-can-i-assert-hasproperty-with-a-java-record
The text was updated successfully, but these errors were encountered: