use of org.springframework.data.cassandra.core.mapping.event.ReactiveBeforeConvertCallback in project spring-data-cassandra by spring-projects.
the class ReactiveCassandraTemplateUnitTests method setUp.
@BeforeEach
void setUp() {
when(driverContext.getCodecRegistry()).thenReturn(codecRegistry);
when(session.getContext()).thenReturn(driverContext);
when(session.execute(any(Statement.class))).thenReturn(Mono.just(reactiveResultSet));
when(row.getColumnDefinitions()).thenReturn(columnDefinitions);
ReactiveEntityCallbacks callbacks = ReactiveEntityCallbacks.create();
callbacks.addEntityCallback((ReactiveBeforeSaveCallback<Object>) (entity, tableName, statement) -> {
assertThat(tableName).isNotNull();
assertThat(statement).isNotNull();
beforeSave = entity;
return Mono.just(entity);
});
callbacks.addEntityCallback((ReactiveBeforeConvertCallback<Object>) (entity, tableName) -> {
assertThat(tableName).isNotNull();
beforeConvert = entity;
return Mono.just(entity);
});
template = new ReactiveCassandraTemplate(session);
template.setUsePreparedStatements(false);
template.setEntityCallbacks(callbacks);
}
Aggregations