Consider annotated methods in AnnotationRevisionMetadata.

We now detect annotated methods.

Closes #2569
This commit is contained in:
Mark Paluch
2022-03-02 14:22:30 +01:00
committed by Jens Schauder
parent 8e241b1938
commit 6bc28c118c
3 changed files with 47 additions and 1 deletions

View File

@@ -33,6 +33,7 @@ import org.springframework.data.annotation.Reference;
*
* @author Oliver Gierke
* @author Jens Schauder
* @author Mark Paluch
*/
class AnnotationRevisionMetadataUnitTests {
@@ -83,6 +84,21 @@ class AnnotationRevisionMetadataUnitTests {
softly.assertAll();
}
@Test // GH-2569
void exposesRevisionMetadataUsingMethodAccessors() {
SampleWithMethodAnnotations sample = new SampleWithMethodAnnotations();
sample.revisionNumber = 1L;
sample.revisionDate = Instant.now();
RevisionMetadata<Long> metadata = getMetadata(sample);
softly.assertThat(metadata.getRevisionNumber()).hasValue(1L);
softly.assertThat(metadata.getRevisionInstant()).hasValue(sample.revisionDate);
softly.assertAll();
}
@Test // DATACMNS-1251
void exposesRevisionDateAndInstantForInstant() {
@@ -149,6 +165,22 @@ class AnnotationRevisionMetadataUnitTests {
@Reference LocalDateTime revisionDate;
}
static class SampleWithMethodAnnotations {
Long revisionNumber;
Instant revisionDate;
@Autowired
public Long getRevisionNumber() {
return revisionNumber;
}
@Reference
public Instant getRevisionDate() {
return revisionDate;
}
}
static class SampleWithInstant {
@Autowired Long revisionNumber;