Search in sources :

Example 6 with SkipExistingDocumentsUpdateProcessor

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

the class SkipExistingDocumentsProcessorFactoryTest method testSkipInsertsAndUpdatesDefaultToTrueIfNotConfigured.

@Test
public void testSkipInsertsAndUpdatesDefaultToTrueIfNotConfigured() {
    SkipExistingDocumentsProcessorFactory factory = new SkipExistingDocumentsProcessorFactory();
    NamedList<Object> initArgs = new NamedList<>();
    factory.init(initArgs);
    UpdateRequestProcessor next = Mockito.mock(DistributedUpdateProcessor.class);
    SkipExistingDocumentsUpdateProcessor processor = factory.getInstance(defaultRequest, new SolrQueryResponse(), next);
    assertTrue("Expected skipInsertIfExists to be true", 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 7 with SkipExistingDocumentsUpdateProcessor

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

the class SkipExistingDocumentsProcessorFactoryTest method testSkippableInsertIsNotSkippedIfNotLeader.

// Tests for logic in the processor
@Test
public void testSkippableInsertIsNotSkippedIfNotLeader() throws IOException {
    UpdateRequestProcessor next = Mockito.mock(DistributedUpdateProcessor.class);
    SkipExistingDocumentsUpdateProcessor processor = Mockito.spy(new SkipExistingDocumentsUpdateProcessor(defaultRequest, next, true, true));
    AddUpdateCommand cmd = createInsertUpdateCmd(defaultRequest);
    doReturn(false).when(processor).isLeader(cmd);
    doReturn(true).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 8 with SkipExistingDocumentsUpdateProcessor

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

the class SkipExistingDocumentsProcessorFactoryTest method testSkippableUpdateIsSkippedIfSkipUpdatesTrue.

@Test
public void testSkippableUpdateIsSkippedIfSkipUpdatesTrue() throws IOException {
    UpdateRequestProcessor next = Mockito.mock(DistributedUpdateProcessor.class);
    SkipExistingDocumentsUpdateProcessor processor = Mockito.spy(new SkipExistingDocumentsUpdateProcessor(defaultRequest, next, false, true));
    AddUpdateCommand cmd = createAtomicUpdateCmd(defaultRequest);
    doReturn(true).when(processor).isLeader(cmd);
    doReturn(false).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 9 with SkipExistingDocumentsUpdateProcessor

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

the class SkipExistingDocumentsProcessorFactoryTest method testSkipUpdatesFalseIfInInitArgs.

@Test
public void testSkipUpdatesFalseIfInInitArgs() {
    SkipExistingDocumentsProcessorFactory factory = new SkipExistingDocumentsProcessorFactory();
    NamedList<Object> initArgs = new NamedList<>();
    initArgs.add("skipUpdateIfMissing", false);
    factory.init(initArgs);
    UpdateRequestProcessor next = Mockito.mock(DistributedUpdateProcessor.class);
    SkipExistingDocumentsUpdateProcessor processor = factory.getInstance(defaultRequest, new SolrQueryResponse(), next);
    assertTrue("Expected skipInsertIfExists to be true", processor.isSkipInsertIfExists());
    assertFalse("Expected skipUpdateIfMissing to be false", 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 10 with SkipExistingDocumentsUpdateProcessor

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

the class SkipExistingDocumentsProcessorFactoryTest method testSkipUpdatesTrueIfInitArgsFalseButTrueStringInRequest.

@Test
public void testSkipUpdatesTrueIfInitArgsFalseButTrueStringInRequest() {
    SkipExistingDocumentsProcessorFactory factory = new SkipExistingDocumentsProcessorFactory();
    NamedList<Object> initArgs = new NamedList<>();
    initArgs.add("skipInsertIfExists", true);
    initArgs.add("skipUpdateIfMissing", false);
    factory.init(initArgs);
    NamedList<Object> requestArgs = new NamedList<>();
    requestArgs.add("skipUpdateIfMissing", "true");
    SolrQueryRequest req = new LocalSolrQueryRequest(null, requestArgs);
    UpdateRequestProcessor next = Mockito.mock(DistributedUpdateProcessor.class);
    SkipExistingDocumentsUpdateProcessor processor = factory.getInstance(req, new SolrQueryResponse(), next);
    assertTrue("Expected skipInsertIfExists to be true", processor.isSkipInsertIfExists());
    assertTrue("Expected skipUpdateIfMissing to be true", processor.isSkipUpdateIfMissing());
}
Also used : LocalSolrQueryRequest(org.apache.solr.request.LocalSolrQueryRequest) LocalSolrQueryRequest(org.apache.solr.request.LocalSolrQueryRequest) SolrQueryRequest(org.apache.solr.request.SolrQueryRequest) 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)

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