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);
}
}
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")));
}
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()));
}
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);
}
}
Aggregations