DATACMNS-1290 - Added support for timestamp values of type long.
The type long or Long is actually required for custom revision entities by Envers. See also: https://github.com/spring-projects/spring-data-envers/issues/122 Original pull request: #282.
This commit is contained in:
committed by
Mark Paluch
parent
5e2e51b7a0
commit
5901a27130
@@ -106,6 +106,26 @@ public class AnnotationRevisionMetadataUnitTests {
|
||||
softly.assertAll();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1290
|
||||
public void exposesRevisionDateAndInstantForLong() {
|
||||
|
||||
SampleWithLong sample = new SampleWithLong();
|
||||
sample.revisionLong = 4711L;
|
||||
|
||||
Instant expectedInstant = Instant.ofEpochMilli(sample.revisionLong);
|
||||
LocalDateTime expectedLocalDateTime = LocalDateTime.ofInstant(expectedInstant, ZoneOffset.systemDefault());
|
||||
|
||||
RevisionMetadata<Long> metadata = getMetadata(sample);
|
||||
|
||||
softly.assertThat(metadata.getRevisionDate()).hasValue(expectedLocalDateTime);
|
||||
softly.assertThat(metadata.getRequiredRevisionDate()).isEqualTo(expectedLocalDateTime);
|
||||
|
||||
softly.assertThat(metadata.getRevisionInstant()).hasValue(expectedInstant);
|
||||
softly.assertThat(metadata.getRequiredRevisionInstant()).isEqualTo(expectedInstant);
|
||||
|
||||
softly.assertAll();
|
||||
}
|
||||
|
||||
private static RevisionMetadata<Long> getMetadata(Object sample) {
|
||||
return new AnnotationRevisionMetadata<>(sample, Autowired.class, Reference.class);
|
||||
}
|
||||
@@ -121,4 +141,10 @@ public class AnnotationRevisionMetadataUnitTests {
|
||||
@Autowired Long revisionNumber;
|
||||
@Reference Instant revisionInstant;
|
||||
}
|
||||
|
||||
static class SampleWithLong {
|
||||
|
||||
@Autowired Long revisionNumber;
|
||||
@Reference long revisionLong;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user