use of org.springframework.data.auditing.IsNewAwareAuditingHandler in project spring-data-mongodb by spring-projects.
the class AuditingEntityCallbackUnitTests method propagatesChangedInstanceToEvent.
// DATAMONGO-2261
@Test
void propagatesChangedInstanceToEvent() {
ImmutableSample sample = new ImmutableSample();
ImmutableSample newSample = new ImmutableSample();
IsNewAwareAuditingHandler handler = mock(IsNewAwareAuditingHandler.class);
doReturn(newSample).when(handler).markAudited(eq(sample));
AuditingEntityCallback listener = new AuditingEntityCallback(() -> handler);
Object result = listener.onBeforeConvert(sample, "foo");
assertThat(result).isSameAs(newSample);
}
use of org.springframework.data.auditing.IsNewAwareAuditingHandler in project spring-data-mongodb by spring-projects.
the class AuditingEventListenerUnitTests method propagatesChangedInstanceToEvent.
// DATAMONGO-1992
@Test
void propagatesChangedInstanceToEvent() {
ImmutableSample sample = new ImmutableSample();
BeforeConvertEvent<Object> event = new BeforeConvertEvent<>(sample, "collection");
ImmutableSample newSample = new ImmutableSample();
IsNewAwareAuditingHandler handler = mock(IsNewAwareAuditingHandler.class);
doReturn(newSample).when(handler).markAudited(eq(sample));
AuditingEventListener listener = new AuditingEventListener(() -> handler);
listener.onApplicationEvent(event);
assertThat(event.getSource()).isSameAs(newSample);
}
use of org.springframework.data.auditing.IsNewAwareAuditingHandler in project spring-data-mongodb by spring-projects.
the class AuditingEntityCallbackUnitTests method setUp.
@BeforeEach
void setUp() {
MongoMappingContext mappingContext = new MongoMappingContext();
mappingContext.getPersistentEntity(Sample.class);
handler = spy(new IsNewAwareAuditingHandler(new PersistentEntities(Arrays.asList(mappingContext))));
callback = new AuditingEntityCallback(() -> handler);
}
use of org.springframework.data.auditing.IsNewAwareAuditingHandler in project spring-data-mongodb by spring-projects.
the class AuditingEventListenerUnitTests method setUp.
@BeforeEach
void setUp() {
MongoMappingContext mappingContext = new MongoMappingContext();
mappingContext.getPersistentEntity(Sample.class);
handler = spy(new IsNewAwareAuditingHandler(new PersistentEntities(Arrays.asList(mappingContext))));
listener = new AuditingEventListener(() -> handler);
}
Aggregations