Search in sources :

Example 1 with SkipExistingDocumentsUpdateProcessor

use of org.apache.solr.update.processor.SkipExistingDocumentsProcessorFactory.SkipExistingDocumentsUpdateProcessor in project lucene-solr by apache.

the class SkipExistingDocumentsProcessorFactoryTest method testNonSkippableInsertIsNotSkippedIfSkipInsertsTrue.

@Test
public void testNonSkippableInsertIsNotSkippedIfSkipInsertsTrue() throws IOException {
    UpdateRequestProcessor next = Mockito.mock(DistributedUpdateProcessor.class);
    SkipExistingDocumentsUpdateProcessor processor = Mockito.spy(new SkipExistingDocumentsUpdateProcessor(defaultRequest, next, true, false));
    AddUpdateCommand cmd = createInsertUpdateCmd(defaultRequest);
    doReturn(true).when(processor).isLeader(cmd);
    doReturn(false).when(processor).doesDocumentExist(docId);
    processor.processAdd(cmd);
    verify(next).processAdd(cmd);
}
Also used : AddUpdateCommand(org.apache.solr.update.AddUpdateCommand) SkipExistingDocumentsUpdateProcessor(org.apache.solr.update.processor.SkipExistingDocumentsProcessorFactory.SkipExistingDocumentsUpdateProcessor) Test(org.junit.Test)

Example 2 with SkipExistingDocumentsUpdateProcessor

use of org.apache.solr.update.processor.SkipExistingDocumentsProcessorFactory.SkipExistingDocumentsUpdateProcessor in project lucene-solr by apache.

the class SkipExistingDocumentsProcessorFactoryTest method testSkippableInsertIsSkippedIfSkipInsertsTrue.

@Test
public void testSkippableInsertIsSkippedIfSkipInsertsTrue() throws IOException {
    UpdateRequestProcessor next = Mockito.mock(DistributedUpdateProcessor.class);
    SkipExistingDocumentsUpdateProcessor processor = Mockito.spy(new SkipExistingDocumentsUpdateProcessor(defaultRequest, next, true, false));
    AddUpdateCommand cmd = createInsertUpdateCmd(defaultRequest);
    doReturn(true).when(processor).isLeader(cmd);
    doReturn(true).when(processor).doesDocumentExist(docId);
    processor.processAdd(cmd);
    verify(next, never()).processAdd(cmd);
}
Also used : AddUpdateCommand(org.apache.solr.update.AddUpdateCommand) SkipExistingDocumentsUpdateProcessor(org.apache.solr.update.processor.SkipExistingDocumentsProcessorFactory.SkipExistingDocumentsUpdateProcessor) Test(org.junit.Test)

Example 3 with SkipExistingDocumentsUpdateProcessor

use of org.apache.solr.update.processor.SkipExistingDocumentsProcessorFactory.SkipExistingDocumentsUpdateProcessor in project lucene-solr by apache.

the class SkipExistingDocumentsProcessorFactoryTest method testSkipInsertsFalseIfInInitArgs.

@Test
public void testSkipInsertsFalseIfInInitArgs() {
    SkipExistingDocumentsProcessorFactory factory = new SkipExistingDocumentsProcessorFactory();
    NamedList<Object> initArgs = new NamedList<>();
    initArgs.add("skipInsertIfExists", false);
    factory.init(initArgs);
    UpdateRequestProcessor next = Mockito.mock(DistributedUpdateProcessor.class);
    SkipExistingDocumentsUpdateProcessor processor = factory.getInstance(defaultRequest, new SolrQueryResponse(), next);
    assertFalse("Expected skipInsertIfExists to be false", processor.isSkipInsertIfExists());
    assertTrue("Expected skipUpdateIfMissing to be true", processor.isSkipUpdateIfMissing());
}
Also used : SolrQueryResponse(org.apache.solr.response.SolrQueryResponse) NamedList(org.apache.solr.common.util.NamedList) SkipExistingDocumentsUpdateProcessor(org.apache.solr.update.processor.SkipExistingDocumentsProcessorFactory.SkipExistingDocumentsUpdateProcessor) Test(org.junit.Test)

Example 4 with SkipExistingDocumentsUpdateProcessor

use of org.apache.solr.update.processor.SkipExistingDocumentsProcessorFactory.SkipExistingDocumentsUpdateProcessor in project lucene-solr by apache.

the class SkipExistingDocumentsProcessorFactoryTest method testSkippableUpdateIsNotSkippedIfNotLeader.

@Test
public void testSkippableUpdateIsNotSkippedIfNotLeader() throws IOException {
    UpdateRequestProcessor next = Mockito.mock(DistributedUpdateProcessor.class);
    SkipExistingDocumentsUpdateProcessor processor = Mockito.spy(new SkipExistingDocumentsUpdateProcessor(defaultRequest, next, true, true));
    AddUpdateCommand cmd = createAtomicUpdateCmd(defaultRequest);
    doReturn(false).when(processor).isLeader(cmd);
    doReturn(false).when(processor).doesDocumentExist(docId);
    processor.processAdd(cmd);
    verify(next).processAdd(cmd);
}
Also used : AddUpdateCommand(org.apache.solr.update.AddUpdateCommand) SkipExistingDocumentsUpdateProcessor(org.apache.solr.update.processor.SkipExistingDocumentsProcessorFactory.SkipExistingDocumentsUpdateProcessor) Test(org.junit.Test)

Example 5 with SkipExistingDocumentsUpdateProcessor

use of org.apache.solr.update.processor.SkipExistingDocumentsProcessorFactory.SkipExistingDocumentsUpdateProcessor in project lucene-solr by apache.

the class SkipExistingDocumentsProcessorFactoryTest method testSkippableUpdateIsNotSkippedIfSkipUpdatesFalse.

@Test
public void testSkippableUpdateIsNotSkippedIfSkipUpdatesFalse() throws IOException {
    UpdateRequestProcessor next = Mockito.mock(DistributedUpdateProcessor.class);
    SkipExistingDocumentsUpdateProcessor processor = Mockito.spy(new SkipExistingDocumentsUpdateProcessor(defaultRequest, next, false, false));
    AddUpdateCommand cmd = createAtomicUpdateCmd(defaultRequest);
    doReturn(true).when(processor).isLeader(cmd);
    doReturn(false).when(processor).doesDocumentExist(docId);
    processor.processAdd(cmd);
    verify(next).processAdd(cmd);
}
Also used : AddUpdateCommand(org.apache.solr.update.AddUpdateCommand) SkipExistingDocumentsUpdateProcessor(org.apache.solr.update.processor.SkipExistingDocumentsProcessorFactory.SkipExistingDocumentsUpdateProcessor) Test(org.junit.Test)

Aggregations

SkipExistingDocumentsUpdateProcessor (org.apache.solr.update.processor.SkipExistingDocumentsProcessorFactory.SkipExistingDocumentsUpdateProcessor)15 Test (org.junit.Test)15 AddUpdateCommand (org.apache.solr.update.AddUpdateCommand)8 NamedList (org.apache.solr.common.util.NamedList)7 SolrQueryResponse (org.apache.solr.response.SolrQueryResponse)7 LocalSolrQueryRequest (org.apache.solr.request.LocalSolrQueryRequest)3 SolrQueryRequest (org.apache.solr.request.SolrQueryRequest)3