Add annotation Class navigation method#3373
Add annotation Class navigation method#3373michaelcowan wants to merge 5 commits intoassertj:mainfrom
Conversation
|
What about a navigation method to change the object under test? Something like: assertThat(MyService.class)
.annotation(Transactional.class) // would return an AbstractObjectAssert<?, Transactional>
.extracting(Transactional::noRollbackFor)
.isEqualTo(SendMailFailureException.class)); |
|
@scordio That was actually my first instinct too, but I changed my mind when I considered:
This made me think that what we are missing is a Happy to change this, I just want to be sure that what we want is to have both: assertThat(MyService.class)
.hasAnnotation(Transactional.class);-and- assertThat(MyService.class)
.annotation(Transactional.class)
// ... |
|
We discussed it internally and we would generally favor navigation methods for new APIs.
As a side note, |
|
@scordio Understood - I've pushed those changes to the branch. |
|
@scordio Do you want me to open a new PR and close this one? |
ff425d7 to
481920b
Compare
301ca01 to
c730d18
Compare
|
@scordio If there anything from me blocking this being merged? |
|
@michaelcowan no, not at all. We are focusing on releasing the first milestone of version 4 and haven't had the chance to finalize your PR. I'll schedule these changes for M2, and apologies for the extremely slow feedback! |
| @Nested | ||
| class With_Repeatable_Annotation { | ||
|
|
||
| // TODO | ||
|
|
||
| } |
There was a problem hiding this comment.
We lack coverage for repeatable annotations. I'll look into that first with hasAnnotation and hasAnnotations, and align this branch later on.
There was a problem hiding this comment.
More coverage for hasAnnotation done in #3823. Another set of changes will follow for hasAnnotations, and then the same will be applied to this branch.
b6e46b9 to
3f3b814
Compare
b2b071f to
2dab02c
Compare
Check List:
Add
hasAnnotationSatisfyingClass assertion.This can be useful when needing to both assert that an annotation is present but also has specific parameter values
e.g., A Spring Boot engineer might want to verify specifically configured transactionals: