use of org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext in project spring-data-elasticsearch by spring-projects.
the class AuditingEntityCallbackTests method setUp.
@BeforeEach
void setUp() {
SimpleElasticsearchMappingContext context = new SimpleElasticsearchMappingContext();
context.getPersistentEntity(Sample.class);
handler = spy(new IsNewAwareAuditingHandler(PersistentEntities.of(context)));
callback = new AuditingEntityCallback(() -> handler);
}
use of org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext in project spring-data-elasticsearch by spring-projects.
the class MappingElasticsearchConverterUnitTests method shouldReturnMappingContextWithWhichItWasInitialized.
@Test
public void shouldReturnMappingContextWithWhichItWasInitialized() {
// given
MappingContext mappingContext = new SimpleElasticsearchMappingContext();
MappingElasticsearchConverter converter = new MappingElasticsearchConverter(mappingContext);
// then
assertThat(converter.getMappingContext()).isNotNull();
assertThat(converter.getMappingContext()).isSameAs(mappingContext);
}
use of org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext in project spring-data-elasticsearch by spring-projects.
the class ReactiveAuditingIntegrationTest method shouldEnableAuditingAndSetAuditingDates.
// DATAES-68
@Test
void shouldEnableAuditingAndSetAuditingDates() throws InterruptedException {
SimpleElasticsearchMappingContext mappingContext = applicationContext.getBean(SimpleElasticsearchMappingContext.class);
mappingContext.getPersistentEntity(Entity.class);
ReactiveEntityCallbacks callbacks = ReactiveEntityCallbacks.create(applicationContext);
Entity entity = new Entity();
entity.setId("1");
entity = callbacks.callback(ReactiveBeforeConvertCallback.class, entity, IndexCoordinates.of("index")).block();
assertThat(entity.getCreated()).isNotNull();
assertThat(entity.getModified()).isEqualTo(entity.created);
assertThat(entity.getCreatedBy()).isEqualTo("Auditor 1");
assertThat(entity.getModifiedBy()).isEqualTo("Auditor 1");
Thread.sleep(10);
entity = callbacks.callback(ReactiveBeforeConvertCallback.class, entity, IndexCoordinates.of("index")).block();
assertThat(entity.getCreated()).isNotNull();
assertThat(entity.getModified()).isNotEqualTo(entity.created);
assertThat(entity.getCreatedBy()).isEqualTo("Auditor 1");
assertThat(entity.getModifiedBy()).isEqualTo("Auditor 2");
}
Aggregations