DATACMNS-1333 - Unified is-new-detection in PersistentEntity.isNew(…).

PersistentEntity now exposes an ….isNew(…) method that exposes the same detection algorithm previously exposed through MappingContextIsNewStrategyFactory (Persistable in favor of the version property in favor of an identifier lookup). MappingContextIsNewStrategyFactory  has been refactored to return an ad-hoc strategy to delegate to the newly introduced method.

The core message to implementing modules is that they should now prefer PersistentEntityInformation within their RepositoryFactorySupport implementation and move all customizations made in the store-specific EntityInformation implementation in PersistentEntity.
This commit is contained in:
Oliver Gierke
2018-05-31 15:30:18 +02:00
parent 6f7b8cee50
commit fc2135df3d
15 changed files with 383 additions and 84 deletions

View File

@@ -16,7 +16,6 @@
package org.springframework.data.auditing;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
import java.util.Optional;
@@ -41,12 +40,15 @@ public class IsNewAwareAuditingHandlerUnitTests extends AuditingHandlerUnitTests
@Before
public void init() {
this.mappingContext = new SampleMappingContext();
this.mappingContext.getPersistentEntity(AuditedUser.class);
this.mappingContext.afterPropertiesSet();
}
@Override
protected IsNewAwareAuditingHandler getHandler() {
return new IsNewAwareAuditingHandler(mock(PersistentEntities.class));
return new IsNewAwareAuditingHandler(PersistentEntities.of(mappingContext));
}
@Test