use of com.yahoo.document.DocumentId in project vespa by vespa-engine.
the class FailingDocumentProcessingTestCase method assertProcessingWorks.
protected void assertProcessingWorks(DocprocService service) {
// Create documents
DocumentType type = new DocumentType("test");
type.addField("test", DataType.STRING);
DocumentPut put1 = new DocumentPut(type, new DocumentId("doc:failing:test:1"));
DocumentPut put2 = new DocumentPut(type, new DocumentId("doc:failing:test:2"));
DocumentPut put3 = new DocumentPut(type, new DocumentId("doc:failing:test:3"));
// Process them
service.process(put1);
service.process(put2);
service.process(put3);
while (service.doWork()) {
}
// Verify
assertEquals(new StringFieldValue("done 3"), put1.getDocument().getFieldValue("test"));
// Due to exception in 2
assertEquals(new StringFieldValue("done 2"), put2.getDocument().getFieldValue("test"));
assertEquals(new StringFieldValue("done 3"), put3.getDocument().getFieldValue("test"));
}
use of com.yahoo.document.DocumentId in project vespa by vespa-engine.
the class FailingPermanentlyDocumentProcessingTestCase method assertProcessingWorks.
protected void assertProcessingWorks(DocprocService service) {
// Create documents
DocumentType type = new DocumentType("test");
type.addField("test", DataType.STRING);
DocumentPut put1 = new DocumentPut(type, new DocumentId("doc:permanentfailure:test:1"));
DocumentPut put2 = new DocumentPut(type, new DocumentId("doc:permanentfailure:test:2"));
DocumentPut put3 = new DocumentPut(type, new DocumentId("doc:permanentfailure:test:3"));
// Process them
service.process(put1);
service.process(put2);
service.process(put3);
while (service.doWork()) {
}
// Verify
assertEquals(new StringFieldValue("done 3"), put1.getDocument().getFieldValue("test"));
// Due to PERMANENT_FAILURE in 2
assertEquals(new StringFieldValue("done 2"), put2.getDocument().getFieldValue("test"));
// service is disabled now
assertNull(put3.getDocument().getFieldValue("test"));
assertFalse(service.isInService());
service.setInService(true);
while (service.doWork()) {
}
assertEquals(new StringFieldValue("done 3"), put3.getDocument().getFieldValue("test"));
assertTrue(service.isInService());
}
use of com.yahoo.document.DocumentId in project vespa by vespa-engine.
the class JsonWriterTestCase method removeTest.
@Test
public void removeTest() {
final DocumentId documentId = new DocumentId("id:unittest:smoke::whee");
InputStream rawDoc = new ByteArrayInputStream(Utf8.toBytes("[" + Utf8.toString(JsonWriter.documentRemove(documentId)) + "]"));
JsonReader r = new JsonReader(types, rawDoc, parserFactory);
DocumentOperation actualRemoveAsBaseType = r.next();
assertSame(DocumentRemove.class, actualRemoveAsBaseType.getClass());
assertEquals(actualRemoveAsBaseType.getId(), documentId);
}
use of com.yahoo.document.DocumentId in project vespa by vespa-engine.
the class ReferenceFieldValueTestCase method reference_can_be_constructed_with_id.
@Test
public void reference_can_be_constructed_with_id() {
DocumentId id = docId("id:ns:foo::itsa-me");
ReferenceFieldValue value = new ReferenceFieldValue(referenceTypeFoo(), id);
assertTrue(value.getDocumentId().isPresent());
assertEquals(id, value.getDocumentId().get());
}
use of com.yahoo.document.DocumentId in project vespa by vespa-engine.
the class VdsStreamingSearcher method verifyDocId.
static boolean verifyDocId(String id, Query query, boolean skippedEarlierResult) {
String expUserId = query.properties().getString(streamingUserid);
String expGroupName = query.properties().getString(streamingGroupname);
LogLevel logLevel = LogLevel.ERROR;
if (skippedEarlierResult) {
logLevel = LogLevel.DEBUG;
}
DocumentId docId;
try {
docId = new DocumentId(id);
} catch (IllegalArgumentException iae) {
log.log(logLevel, "Bad result for " + query + ": " + iae.getMessage());
return false;
}
if (expUserId != null) {
long userId;
if (docId.getScheme().hasNumber()) {
userId = docId.getScheme().getNumber();
} else {
log.log(logLevel, "Got result with wrong scheme (expected " + IdString.Scheme.userdoc + " or " + IdString.Scheme.orderdoc + ") in document ID (" + id + ") for " + query);
return false;
}
if (new BigInteger(expUserId).longValue() != userId) {
log.log(logLevel, "Got result with wrong user ID (expected " + expUserId + ") in document ID (" + id + ") for " + query);
return false;
}
} else if (expGroupName != null) {
String groupName;
if (docId.getScheme().hasGroup()) {
groupName = docId.getScheme().getGroup();
} else {
log.log(logLevel, "Got result with wrong scheme (expected " + IdString.Scheme.groupdoc + " or " + IdString.Scheme.orderdoc + ") in document ID (" + id + ") for " + query);
return false;
}
if (!expGroupName.equals(groupName)) {
log.log(logLevel, "Got result with wrong group name (expected " + expGroupName + ") in document ID (" + id + ") for " + query);
return false;
}
}
return true;
}
Aggregations