inlineReplyThread.getLocation());
}
public void testInsertInlineBlipAfterElement() throws Exception {
OperationContextImpl context = helper.getContext();
ObservableConversation conversation =
context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot();
// Make an inline blip at a certain location, we will then have the
// BlipOperationService insert one after that blip.
ObservableConversationBlip rootBlip = conversation.getRootThread().getFirstBlip();
Document doc = rootBlip.getContent();
Doc.E lastLine = DocHelper.getLastElementWithTagName(doc, LineContainers.LINE_TAGNAME);
int lastLineLocation = doc.getLocation(Point.after(doc, lastLine));
ObservableConversationBlip firstInlineBlip =
rootBlip.addReplyThread(lastLineLocation).appendBlip();
// Append the inline blip to the root blip
String rootBlipId = ConversationUtil.getRootBlipId(conversation);
Element inlineBlipElement = new Element(ElementType.INLINE_BLIP);
inlineBlipElement.setProperty("id", firstInlineBlip.getId());
OperationRequest operation = operationRequest(
OperationType.DOCUMENT_INSERT_INLINE_BLIP_AFTER_ELEMENT, rootBlipId,
Parameter.of(ParamsProperty.BLIP_DATA, blipData),
Parameter.of(ParamsProperty.ELEMENT, inlineBlipElement));
service.execute(operation, context, ALEX);
JsonRpcResponse response = context.getResponse(OPERATION_ID);
assertFalse(response.isError());
ConversationBlip newBlip = checkAndGetNewBlip(context, conversation, response);
// The second InlineReplyThread is created by the BlipOperationService, it
// should be located just after the first one.
Iterator<? extends LocatedReplyThread<?>> it =
conversation.getRootThread().getFirstBlip().locateReplyThreads().iterator();
// Inline blips have a length of 2.
assertEquals("The inline reply was not located where specified", it.next().getLocation() + 2,
it.next().getLocation());
}