DATACMNS-1780 - PersistentEntities allows in flight metadata creation if the associated mapping context can be identified.
Use a more lenient approach, that allows metadata creation, when looking up persistent entities. This allows eg. a configured AuditingHandler to kick in without having to register an initial entity set in first place. Original pull request: #462.
This commit is contained in:
committed by
Mark Paluch
parent
a600d8160c
commit
fd15c099e9
@@ -16,6 +16,7 @@
|
||||
package org.springframework.data.auditing;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -103,6 +104,19 @@ class IsNewAwareAuditingHandlerUnitTests extends AuditingHandlerUnitTests {
|
||||
getHandler().markAudited(Optional.of(new EntityWithoutId()));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1780
|
||||
void singleContextAllowsInFlightMetadataCreationForUnknownPersistentEntities() {
|
||||
|
||||
SampleMappingContext mappingContext = spy(new SampleMappingContext());
|
||||
mappingContext.afterPropertiesSet();
|
||||
|
||||
AuditedUser user = new AuditedUser();
|
||||
user.id = 1L;
|
||||
|
||||
new IsNewAwareAuditingHandler(PersistentEntities.of(mappingContext)).markAudited(user);
|
||||
verify(mappingContext).getPersistentEntity(AuditedUser.class);
|
||||
}
|
||||
|
||||
static class Domain {
|
||||
|
||||
@Id Long id;
|
||||
|
||||
Reference in New Issue
Block a user