use of com.yahoo.document.DocumentId in project vespa by vespa-engine.
the class ReferenceFieldValueTestCase method can_explicitly_set_new_id_for_existing_reference.
@Test
public void can_explicitly_set_new_id_for_existing_reference() {
ReferenceFieldValue value = new ReferenceFieldValue(referenceTypeFoo());
DocumentId newId = docId("id:ns:foo::wario-time");
value.setDocumentId(newId);
assertTrue(value.getDocumentId().isPresent());
assertEquals(newId, value.getDocumentId().get());
}
use of com.yahoo.document.DocumentId in project vespa by vespa-engine.
the class StoragePolicyTestEnvironment method createMessage.
protected static Message createMessage(String id) {
Message msg = new RemoveDocumentMessage(new DocumentId(id));
msg.getTrace().setLevel(9);
return msg;
}
use of com.yahoo.document.DocumentId in project vespa by vespa-engine.
the class JsonReader method readSingleDocument.
/**
* Reads a single operation. The operation is not expected to be part of an array.
* @param operationType the type of operation (update or put)
* @param docIdString document ID.
* @return the document
*/
public DocumentOperation readSingleDocument(DocumentParser.SupportedOperation operationType, String docIdString) {
DocumentId docId = new DocumentId(docIdString);
final DocumentParseInfo documentParseInfo;
try {
DocumentParser documentParser = new DocumentParser(parser);
documentParseInfo = documentParser.parse(Optional.of(docId)).get();
} catch (IOException e) {
state = END_OF_FEED;
throw new RuntimeException(e);
}
documentParseInfo.operationType = operationType;
VespaJsonDocumentReader vespaJsonDocumentReader = new VespaJsonDocumentReader();
DocumentOperation operation = vespaJsonDocumentReader.createDocumentOperation(getDocumentTypeFromString(documentParseInfo.documentId.getDocType(), typeManager), documentParseInfo);
operation.setCondition(TestAndSetCondition.fromConditionString(documentParseInfo.condition));
return operation;
}
use of com.yahoo.document.DocumentId in project vespa by vespa-engine.
the class MessageBusVisitorSessionTestCase method testFailureOnUnknownReplyType.
/**
* Test branch where we don't know how to handle a certain reply type.
* This should never happen (since we only get replies for messages we've
* already sent) but deal with it anyway!
*/
@Test
public void testFailureOnUnknownReplyType() {
MockComponents mc = createDefaultMock("id.user==1234");
mc.visitorSession.start();
mc.controlHandler.resetMock();
mc.executor.expectAndProcessTasks(1);
mc.sender.getAndRemoveMessage(0);
// Make a bogus reply that we never asked for
RemoveDocumentMessage msg = new RemoveDocumentMessage(new DocumentId("doc:foo:bar"));
DocumentReply reply = msg.createReply();
mc.sender.reply(reply);
// reply
mc.executor.expectAndProcessTasks(1);
mc.executor.expectNoTasks();
assertEquals(0, mc.sender.getMessageCount());
assertTrue(mc.visitorSession.isDone());
assertEquals("onDone : FAILURE - 'Received reply we do not know how to " + "handle: com.yahoo.documentapi.messagebus.protocol.RemoveDocumentReply'\n", mc.controlHandler.toString());
}
use of com.yahoo.document.DocumentId in project vespa by vespa-engine.
the class MessageBusVisitorSessionTestCase method testSkipBucketOnFatalMessageProcessingError.
@Test
public void testSkipBucketOnFatalMessageProcessingError() {
VisitorParameters visitorParameters = createVisitorParameters("id.user==1234");
visitorParameters.skipBucketsOnFatalErrors(true);
MockComponents mc = createDefaultMock(visitorParameters);
mc.controlHandler.resetMock();
mc.dataHandler.resetMock();
mc.dataHandler.setExceptionOnMessage(new IllegalArgumentException("oh no"));
mc.visitorSession.start();
mc.executor.expectAndProcessTasks(1);
mc.receiver.send(new RemoveDocumentMessage(new DocumentId("doc:foo:bar")));
mc.executor.expectAndProcessTasks(1);
assertEquals(1, mc.dataHandler.getMessages().size());
// NOTE: current behavior does _not_ fail the session at the end of
// visiting if the CreateVisitor replies do not also return with failure
// since this is tied to the ProgressToken and its failed buckets list.
// We make the simplifying assumption that failing a visitor _message_
// will subsequently cause its reply to fail back to us, allowing us to
// handle this as a regular skippable bucket.
// TODO: reconsider this?
replyErrorToCreateVisitor(mc.sender, new Error(DocumentProtocol.ERROR_INTERNAL_FAILURE, "The Borkening"));
mc.executor.expectAndProcessTasks(1);
mc.executor.expectNoTasks();
assertTrue(mc.controlHandler.isDone());
// Get UNPARSEABLE rather than APP_FATAL_ERROR if skip buckets is set
assertEquals("RemoveDocumentReply(UNPARSEABLE: Got exception of type java.lang.IllegalArgumentException " + "with message 'oh no' while processing DocumentMessage)\n", mc.receiver.repliesToString());
assertEquals("onVisitorError : INTERNAL_FAILURE: The Borkening\n" + "onDone : FAILURE - 'INTERNAL_FAILURE: The Borkening'\n", mc.controlHandler.toString());
assertEquals("FAILURE: INTERNAL_FAILURE: The Borkening", mc.controlHandler.getResult().toString());
}
Aggregations