private ApiView getApiView() throws InvalidRequestException { ApiView view = new ApiView( getRootBlip().getContent(), helper.getContext().openWavelet(WAVE_ID, WAVELET_ID, ALEX)); return view; }
private ApiView getApiView() throws InvalidRequestException { ApiView view = new ApiView( getRootBlip().getContent(), helper.getContext().openWavelet(WAVE_ID, WAVELET_ID, ALEX)); return view; }
@Override protected void setUp() throws Exception { service = WaveletSetTitleService.create(); helper = new OperationServiceHelper(WAVELET_NAME, ALEX); ObservableConversationBlip rootBlip = getRootBlip(); LineContainers.appendToLastLine( rootBlip.getContent(), XmlStringBuilder.createText(INITIAL_CONTENT)); }
public void testAnnotate() throws Exception { OperationRequest operation = operationRequest(OperationType.DOCUMENT_MODIFY, rootBlipId, Parameter.of(ParamsProperty.MODIFY_ACTION, new DocumentModifyAction(ModifyHow.ANNOTATE, Collections.singletonList(ANNOTATION_VALUE), ANNOTATION_KEY, NO_ELEMENTS, NO_BUNDLED_ANNOTATIONS, false)), Parameter.of(ParamsProperty.INDEX, CONTENT_START_TEXT)); service.execute(operation, helper.getContext(), ALEX); String annotation = getRootBlip().getContent().getAnnotation(CONTENT_START_XML, ANNOTATION_KEY); assertEquals("Expected the text to be annotated", ANNOTATION_VALUE, annotation); assertNull("Expected this text not to be annotated", getRootBlip().getContent().getAnnotation(CONTENT_START_XML + 1, ANNOTATION_KEY)); }
@Override protected void setUp() throws Exception { service = WaveletSetTitleService.create(); helper = new OperationServiceHelper(WAVELET_NAME, ALEX); ObservableConversationBlip rootBlip = getRootBlip(); LineContainers.appendToLastLine( rootBlip.getContent(), XmlStringBuilder.createText(INITIAL_CONTENT)); }
public void testDeleteConversationEvents() { ObservableConversationBlip outerBlip = target.getRootThread().appendBlip(); ObservableConversationThread inlineThread = outerBlip.addReplyThread(locateAfterLineElement(outerBlip.getContent())); ObservableConversationBlip innerBlip = inlineThread.appendBlip(); target.addListener(convListener); target.delete(); assertBlipInvalid(outerBlip); assertBlipInvalid(innerBlip); assertThreadInvalid(inlineThread); verify(convListener).onBlipDeleted(innerBlip); verify(convListener).onThreadDeleted(inlineThread); verify(convListener).onBlipDeleted(outerBlip); verifyNoMoreInteractions(convListener); }
public void testAnnotate() throws Exception { OperationRequest operation = operationRequest(OperationType.DOCUMENT_MODIFY, rootBlipId, Parameter.of(ParamsProperty.MODIFY_ACTION, new DocumentModifyAction(ModifyHow.ANNOTATE, Collections.singletonList(ANNOTATION_VALUE), ANNOTATION_KEY, NO_ELEMENTS, NO_BUNDLED_ANNOTATIONS, false)), Parameter.of(ParamsProperty.INDEX, CONTENT_START_TEXT)); service.execute(operation, helper.getContext(), ALEX); String annotation = getRootBlip().getContent().getAnnotation(CONTENT_START_XML, ANNOTATION_KEY); assertEquals("Expected the text to be annotated", ANNOTATION_VALUE, annotation); assertNull("Expected this text not to be annotated", getRootBlip().getContent().getAnnotation(CONTENT_START_XML + 1, ANNOTATION_KEY)); }
public void testClearAnnotatation() throws Exception { Document doc = getRootBlip().getContent(); doc.setAnnotation(CONTENT_START_XML, CONTENT_START_XML + 1, ANNOTATION_KEY, ANNOTATION_VALUE); String annotation = getRootBlip().getContent().getAnnotation(CONTENT_START_XML, ANNOTATION_KEY); assertEquals("Expected the text to be annotated", ANNOTATION_VALUE, annotation); OperationRequest operation = operationRequest(OperationType.DOCUMENT_MODIFY, rootBlipId, Parameter.of(ParamsProperty.MODIFY_ACTION, new DocumentModifyAction(ModifyHow.CLEAR_ANNOTATION, NO_VALUES, ANNOTATION_KEY, NO_ELEMENTS, NO_BUNDLED_ANNOTATIONS, false)), Parameter.of(ParamsProperty.INDEX, CONTENT_START_TEXT)); service.execute(operation, helper.getContext(), ALEX); assertNull("Expected this text not to be annotated", getRootBlip().getContent().getAnnotation(CONTENT_START_XML, ANNOTATION_KEY)); }
public void testClearAnnotatation() throws Exception { Document doc = getRootBlip().getContent(); doc.setAnnotation(CONTENT_START_XML, CONTENT_START_XML + 1, ANNOTATION_KEY, ANNOTATION_VALUE); String annotation = getRootBlip().getContent().getAnnotation(CONTENT_START_XML, ANNOTATION_KEY); assertEquals("Expected the text to be annotated", ANNOTATION_VALUE, annotation); OperationRequest operation = operationRequest(OperationType.DOCUMENT_MODIFY, rootBlipId, Parameter.of(ParamsProperty.MODIFY_ACTION, new DocumentModifyAction(ModifyHow.CLEAR_ANNOTATION, NO_VALUES, ANNOTATION_KEY, NO_ELEMENTS, NO_BUNDLED_ANNOTATIONS, false)), Parameter.of(ParamsProperty.INDEX, CONTENT_START_TEXT)); service.execute(operation, helper.getContext(), ALEX); assertNull("Expected this text not to be annotated", getRootBlip().getContent().getAnnotation(CONTENT_START_XML, ANNOTATION_KEY)); }
public void testDeleteConversationEvents() { ObservableConversationBlip outerBlip = target.getRootThread().appendBlip(); ObservableConversationThread inlineThread = outerBlip.addReplyThread(locateAfterLineElement(outerBlip.getContent())); ObservableConversationBlip innerBlip = inlineThread.appendBlip(); target.addListener(convListener); target.delete(); assertBlipInvalid(outerBlip); assertBlipInvalid(innerBlip); assertThreadInvalid(inlineThread); verify(convListener).onBlipDeleted(innerBlip); verify(convListener).onThreadDeleted(inlineThread); verify(convListener).onBlipDeleted(outerBlip); verifyNoMoreInteractions(convListener); }
@Override protected void setUp() throws Exception { service = DocumentModifyService.create(); helper = new OperationServiceHelper(WAVELET_NAME, ALEX); ObservableConversationBlip rootBlip = getRootBlip(); rootBlipId = rootBlip.getId(); LineContainers.appendToLastLine( rootBlip.getContent(), XmlStringBuilder.createText(INITIAL_CONTENT)); }
@Override protected void setUp() throws Exception { service = DocumentModifyService.create(); helper = new OperationServiceHelper(WAVELET_NAME, ALEX); ObservableConversationBlip rootBlip = getRootBlip(); rootBlipId = rootBlip.getId(); LineContainers.appendToLastLine( rootBlip.getContent(), XmlStringBuilder.createText(INITIAL_CONTENT)); }
public void testInsert() throws Exception { String toInsert = "insertedText"; // Insert a new piece of annotated text before the current text. OperationRequest operation = operationRequest(OperationType.DOCUMENT_MODIFY, rootBlipId, Parameter.of(ParamsProperty.MODIFY_ACTION, new DocumentModifyAction(ModifyHow.INSERT, Collections.singletonList(toInsert), NO_ANNOTATION_KEY, NO_ELEMENTS, BundledAnnotation.listOf(ANNOTATION_KEY, ANNOTATION_VALUE), false)), Parameter.of(ParamsProperty.INDEX, CONTENT_START_TEXT)); service.execute(operation, helper.getContext(), ALEX); // Cut off the /n String result = getApiView().apiContents().substring(1); assertEquals( "The result should start with the inserted text", toInsert + INITIAL_CONTENT, result); String annotation = getRootBlip().getContent().getAnnotation(CONTENT_START_XML, ANNOTATION_KEY); assertEquals("Expected the text to be annotated", ANNOTATION_VALUE, annotation); }
public void testInsert() throws Exception { String toInsert = "insertedText"; // Insert a new piece of annotated text before the current text. OperationRequest operation = operationRequest(OperationType.DOCUMENT_MODIFY, rootBlipId, Parameter.of(ParamsProperty.MODIFY_ACTION, new DocumentModifyAction(ModifyHow.INSERT, Collections.singletonList(toInsert), NO_ANNOTATION_KEY, NO_ELEMENTS, BundledAnnotation.listOf(ANNOTATION_KEY, ANNOTATION_VALUE), false)), Parameter.of(ParamsProperty.INDEX, CONTENT_START_TEXT)); service.execute(operation, helper.getContext(), ALEX); // Cut off the /n String result = getApiView().apiContents().substring(1); assertEquals( "The result should start with the inserted text", toInsert + INITIAL_CONTENT, result); String annotation = getRootBlip().getContent().getAnnotation(CONTENT_START_XML, ANNOTATION_KEY); assertEquals("Expected the text to be annotated", ANNOTATION_VALUE, annotation); }
public void testDeleteConversationInvalidatesNonRootThreads() { ObservableConversationBlip outerBlip = target.getRootThread().appendBlip(); ObservableConversationThread inlineThread = outerBlip.addReplyThread(locateAfterLineElement(outerBlip.getContent())); ObservableConversationBlip innerBlip = inlineThread.appendBlip(); target.addListener(convListener); target.delete(); assertBlipInvalid(outerBlip); assertBlipInvalid(innerBlip); assertThreadInvalid(inlineThread); }
public void testDeleteConversationInvalidatesNonRootThreads() { ObservableConversationBlip outerBlip = target.getRootThread().appendBlip(); ObservableConversationThread inlineThread = outerBlip.addReplyThread(locateAfterLineElement(outerBlip.getContent())); ObservableConversationBlip innerBlip = inlineThread.appendBlip(); target.addListener(convListener); target.delete(); assertBlipInvalid(outerBlip); assertBlipInvalid(innerBlip); assertThreadInvalid(inlineThread); }
public void testSetTitle() throws Exception { String title = "Some title"; OperationRequest operation = new OperationRequest(OperationType.WAVELET_SET_TITLE.method(), WAVELET_ID.getId(), Parameter.of( ParamsProperty.WAVELET_TITLE, title), Parameter.of( ParamsProperty.WAVE_ID, LegacyIdSerialiser.INSTANCE.serialiseWaveId(WAVE_ID)), Parameter.of( ParamsProperty.WAVELET_ID, LegacyIdSerialiser.INSTANCE.serialiseWaveletId(WAVELET_ID))); service.execute(operation, helper.getContext(), ALEX); String annotation = getRootBlip().getContent().getAnnotation(0, TitleHelper.TITLE_KEY); assertEquals("Expected conv/title annotation on range (0,1)", title, annotation); }
public void testAppendInlineBlip() throws Exception { OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); // Append the inline blip to the root blip String rootBlipId = ConversationUtil.getRootBlipId(conversation); OperationRequest operation = operationRequest(OperationType.DOCUMENT_APPEND_INLINE_BLIP, rootBlipId, Parameter.of(ParamsProperty.BLIP_DATA, blipData)); service.execute(operation, context, ALEX); JsonRpcResponse response = context.getResponse(OPERATION_ID); assertFalse(response.isError()); ConversationBlip newBlip = checkAndGetNewBlip(context, conversation, response); Iterator<? extends LocatedReplyThread<? extends ObservableConversationThread>> it = conversation.getRootThread().getFirstBlip().locateReplyThreads().iterator(); LocatedReplyThread<? extends ObservableConversationThread> inlineReplyThread = it.next(); // The inline reply thread should be located just after the last line // element Document doc = conversation.getRootThread().getFirstBlip().getContent(); Doc.E lastLine = DocHelper.getLastElementWithTagName(doc, LineContainers.LINE_TAGNAME); int lastLineLocation = doc.getLocation(Point.after(doc, lastLine)); assertEquals("The inline reply was not located just after the last line element", lastLineLocation, inlineReplyThread.getLocation()); }
public void testInsertInlineBlip() throws Exception { OperationContextImpl context = helper.getContext(); OpBasedWavelet wavelet = context.openWavelet(WAVE_ID, WAVELET_ID, ALEX); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); int insertAtApiLocation = 2; ApiView apiView = new ApiView(conversation.getRootThread().getFirstBlip().getContent(), wavelet); int insertAtXmlLocation = apiView.transformToXmlOffset(insertAtApiLocation); // Append the inline blip to the root blip String rootBlipId = ConversationUtil.getRootBlipId(conversation); OperationRequest operation = operationRequest(OperationType.DOCUMENT_INSERT_INLINE_BLIP, rootBlipId, Parameter.of(ParamsProperty.BLIP_DATA, blipData), Parameter.of(ParamsProperty.INDEX, insertAtApiLocation)); service.execute(operation, context, ALEX); JsonRpcResponse response = context.getResponse(OPERATION_ID); assertFalse(response.isError()); ConversationBlip newBlip = checkAndGetNewBlip(context, conversation, response); Iterator<? extends LocatedReplyThread<? extends ObservableConversationThread>> it = conversation.getRootThread().getFirstBlip().locateReplyThreads().iterator(); LocatedReplyThread<? extends ObservableConversationThread> inlineReplyThread = it.next(); assertEquals("The inline reply was not located where specified", insertAtXmlLocation, inlineReplyThread.getLocation()); }
public void testSetTitle() throws Exception { String title = "Some title"; OperationRequest operation = new OperationRequest(OperationType.WAVELET_SET_TITLE.method(), WAVELET_ID.getId(), Parameter.of( ParamsProperty.WAVELET_TITLE, title), Parameter.of( ParamsProperty.WAVE_ID, LegacyIdSerialiser.INSTANCE.serialiseWaveId(WAVE_ID)), Parameter.of( ParamsProperty.WAVELET_ID, LegacyIdSerialiser.INSTANCE.serialiseWaveletId(WAVELET_ID))); service.execute(operation, helper.getContext(), ALEX); String annotation = getRootBlip().getContent().getAnnotation(0, TitleHelper.TITLE_KEY); assertEquals("Expected conv/title annotation on range (0,1)", title, annotation); }