use of org.apache.geode.cache.lucene.internal.repository.serializer.LuceneSerializer in project geode by apache.
the class IndexRepositorySpy method computeIndexRepository.
@Override
public IndexRepository computeIndexRepository(final Integer bucketId, LuceneSerializer serializer, LuceneIndexImpl index, PartitionedRegion userRegion, IndexRepository oldRepository) throws IOException {
LuceneIndexForPartitionedRegion indexForPR = (LuceneIndexForPartitionedRegion) index;
final IndexRepository indexRepo = super.computeIndexRepository(bucketId, serializer, index, userRegion, oldRepository);
if (indexRepo == null) {
return null;
}
if (mockingDetails(indexRepo).isSpy()) {
return indexRepo;
}
final IndexRepository spy = Mockito.spy(indexRepo);
Answer invokeBeforeWrite = invocation -> {
beforeWrite.accept(invocation.getArgumentAt(0, Object.class));
return invocation.callRealMethod();
};
doAnswer(invokeBeforeWrite).when(spy).update(any(), any());
doAnswer(invokeBeforeWrite).when(spy).create(any(), any());
doAnswer(invokeBeforeWrite).when(spy).delete(any());
return spy;
}
Aggregations