Search in sources :

Example 6 with ToleratedUpdateError

use of org.apache.solr.common.ToleratedUpdateError in project lucene-solr by apache.

the class TestToleratedUpdateError method testParseMap.

public void testParseMap() {
    // trivial
    SimpleOrderedMap valid = new SimpleOrderedMap<String>();
    valid.add("type", CmdType.ADD.toString());
    valid.add("id", "some id");
    valid.add("message", "some message");
    ToleratedUpdateError in = ToleratedUpdateError.parseMap(valid);
    compare(in, MAP_COPPIER);
    compare(in, METADATA_COPPIER);
    // randomized
    int numIters = atLeast(5000);
    for (int i = 0; i < numIters; i++) {
        valid = new SimpleOrderedMap<String>();
        valid.add("type", ALL_TYPES[TestUtil.nextInt(random(), 0, ALL_TYPES.length - 1)].toString());
        valid.add("id", TestUtil.randomUnicodeString(random()));
        valid.add("message", TestUtil.randomUnicodeString(random()));
        in = ToleratedUpdateError.parseMap(valid);
        compare(in, MAP_COPPIER);
        compare(in, METADATA_COPPIER);
    }
}
Also used : ToleratedUpdateError(org.apache.solr.common.ToleratedUpdateError) SimpleOrderedMap(org.apache.solr.common.util.SimpleOrderedMap)

Example 7 with ToleratedUpdateError

use of org.apache.solr.common.ToleratedUpdateError in project lucene-solr by apache.

the class TestToleratedUpdateError method testBasics.

public void testBasics() {
    assertFalse((new ToleratedUpdateError(CmdType.ADD, "doc1", "some error")).equals(new ToleratedUpdateError(CmdType.ADD, "doc2", "some error")));
    assertFalse((new ToleratedUpdateError(CmdType.ADD, "doc1", "some error")).equals(new ToleratedUpdateError(CmdType.ADD, "doc1", "some errorxx")));
    assertFalse((new ToleratedUpdateError(CmdType.ADD, "doc1", "some error")).equals(new ToleratedUpdateError(CmdType.DELID, "doc1", "some error")));
}
Also used : ToleratedUpdateError(org.apache.solr.common.ToleratedUpdateError)

Example 8 with ToleratedUpdateError

use of org.apache.solr.common.ToleratedUpdateError in project lucene-solr by apache.

the class TestToleratedUpdateError method testParseMetadataErrorHandling.

public void testParseMetadataErrorHandling() {
    assertNull(ToleratedUpdateError.parseMetadataIfToleratedUpdateError("some other key", "some value"));
    // see if someone tries to trick us into having an NPE...
    ToleratedUpdateError valid = new ToleratedUpdateError(CmdType.ADD, "doc2", "some error");
    String badKey = valid.getMetadataKey().replace(":", "X");
    assertNull(ToleratedUpdateError.parseMetadataIfToleratedUpdateError(badKey, valid.getMetadataValue()));
}
Also used : ToleratedUpdateError(org.apache.solr.common.ToleratedUpdateError)

Example 9 with ToleratedUpdateError

use of org.apache.solr.common.ToleratedUpdateError in project lucene-solr by apache.

the class TestToleratedUpdateError method checkRoundTripComparisons.

public void checkRoundTripComparisons(Coppier coppier) {
    // some simple basics
    for (ToleratedUpdateError in : new ToleratedUpdateError[] { new ToleratedUpdateError(CmdType.ADD, "doc1", "some error"), new ToleratedUpdateError(CmdType.DELID, "doc1", "some diff error"), new ToleratedUpdateError(CmdType.DELQ, "-field:yakko other_field:wakko", "some other error") }) {
        compare(in, coppier);
    }
    // randomized testing of non trivial keys/values
    int numIters = atLeast(5000);
    for (int i = 0; i < numIters; i++) {
        ToleratedUpdateError in = new ToleratedUpdateError(ALL_TYPES[TestUtil.nextInt(random(), 0, ALL_TYPES.length - 1)], TestUtil.randomUnicodeString(random()), TestUtil.randomUnicodeString(random()));
        compare(in, coppier);
    }
}
Also used : ToleratedUpdateError(org.apache.solr.common.ToleratedUpdateError)

Aggregations

ToleratedUpdateError (org.apache.solr.common.ToleratedUpdateError)9 SolrException (org.apache.solr.common.SolrException)3 NamedList (org.apache.solr.common.util.NamedList)3 ArrayList (java.util.ArrayList)2 LinkedHashSet (java.util.LinkedHashSet)2 Set (java.util.Set)2 UpdateResponse (org.apache.solr.client.solrj.response.UpdateResponse)2 SimpleOrderedMap (org.apache.solr.common.util.SimpleOrderedMap)2 HashMap (java.util.HashMap)1 List (java.util.List)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 BytesRef (org.apache.lucene.util.BytesRef)1 SolrInputDocument (org.apache.solr.common.SolrInputDocument)1