Search in sources :

Example 1 with LuceneSerializer

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;
}
Also used : Matchers.any(org.mockito.Matchers.any) Consumer(java.util.function.Consumer) Mockito(org.mockito.Mockito) Answer(org.mockito.stubbing.Answer) IndexRepositoryFactory(org.apache.geode.cache.lucene.internal.IndexRepositoryFactory) LuceneIndexForPartitionedRegion(org.apache.geode.cache.lucene.internal.LuceneIndexForPartitionedRegion) IOException(java.io.IOException) LuceneSerializer(org.apache.geode.cache.lucene.internal.repository.serializer.LuceneSerializer) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) LuceneIndexImpl(org.apache.geode.cache.lucene.internal.LuceneIndexImpl) PartitionedRepositoryManager(org.apache.geode.cache.lucene.internal.PartitionedRepositoryManager) IndexRepository(org.apache.geode.cache.lucene.internal.repository.IndexRepository) Answer(org.mockito.stubbing.Answer) IndexRepository(org.apache.geode.cache.lucene.internal.repository.IndexRepository) LuceneIndexForPartitionedRegion(org.apache.geode.cache.lucene.internal.LuceneIndexForPartitionedRegion)

Aggregations

IOException (java.io.IOException)1 Consumer (java.util.function.Consumer)1 IndexRepositoryFactory (org.apache.geode.cache.lucene.internal.IndexRepositoryFactory)1 LuceneIndexForPartitionedRegion (org.apache.geode.cache.lucene.internal.LuceneIndexForPartitionedRegion)1 LuceneIndexImpl (org.apache.geode.cache.lucene.internal.LuceneIndexImpl)1 PartitionedRepositoryManager (org.apache.geode.cache.lucene.internal.PartitionedRepositoryManager)1 IndexRepository (org.apache.geode.cache.lucene.internal.repository.IndexRepository)1 LuceneSerializer (org.apache.geode.cache.lucene.internal.repository.serializer.LuceneSerializer)1 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)1 Matchers.any (org.mockito.Matchers.any)1 Mockito (org.mockito.Mockito)1 Answer (org.mockito.stubbing.Answer)1