public static DocumentModifyService create() { return new DocumentModifyService(); } }
DocumentHitIterator hitIterator = getDocumentHitIterator(operation, view); annotate(operation, doc, view, hitIterator, modifyAction); break; case CLEAR_ANNOTATION: clearAnnotation(operation, doc, view, hitIterator, modifyAction); break; case DELETE: delete(operation, view, hitIterator); break; case INSERT: insert(operation, doc, view, hitIterator, modifyAction); break; case INSERT_AFTER: insertAfter(operation, doc, view, hitIterator, modifyAction); break; case REPLACE: replace(operation, doc, view, hitIterator, modifyAction); break; case UPDATE_ELEMENT: updateElement(operation, doc, view, hitIterator, modifyAction); break; default:
public void testInsertAfter() throws Exception { String toInsert = "insertedText"; OperationRequest operation = operationRequest(OperationType.DOCUMENT_MODIFY, rootBlipId, Parameter.of(ParamsProperty.MODIFY_ACTION, new DocumentModifyAction(ModifyHow.INSERT_AFTER, Collections.singletonList(toInsert), NO_ANNOTATION_KEY, NO_ELEMENTS, NO_BUNDLED_ANNOTATIONS, false)), Parameter.of(ParamsProperty.INDEX, CONTENT_START_TEXT)); service.execute(operation, helper.getContext(), ALEX); // Cut off the /n String after = getApiView().apiContents().substring(1); assertEquals("Content should be insterted after the first character", INITIAL_CONTENT.charAt(0) + toInsert + INITIAL_CONTENT.substring(1), after); }
@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 testInsertAfter() throws Exception { String toInsert = "insertedText"; OperationRequest operation = operationRequest(OperationType.DOCUMENT_MODIFY, rootBlipId, Parameter.of(ParamsProperty.MODIFY_ACTION, new DocumentModifyAction(ModifyHow.INSERT_AFTER, Collections.singletonList(toInsert), NO_ANNOTATION_KEY, NO_ELEMENTS, NO_BUNDLED_ANNOTATIONS, false)), Parameter.of(ParamsProperty.INDEX, CONTENT_START_TEXT)); service.execute(operation, helper.getContext(), ALEX); // Cut off the /n String after = getApiView().apiContents().substring(1); assertEquals("Content should be insterted after the first character", INITIAL_CONTENT.charAt(0) + toInsert + INITIAL_CONTENT.substring(1), after); }
@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 testDelete() throws Exception { OperationRequest operation = operationRequest(OperationType.DOCUMENT_MODIFY, rootBlipId, Parameter.of(ParamsProperty.MODIFY_ACTION, new DocumentModifyAction(ModifyHow.DELETE, NO_VALUES, NO_ANNOTATION_KEY, NO_ELEMENTS, NO_BUNDLED_ANNOTATIONS, false)), Parameter.of(ParamsProperty.INDEX, CONTENT_START_TEXT)); service.execute(operation, helper.getContext(), ALEX); // Cut off the /n String after = getApiView().apiContents().substring(1); assertEquals("First character should be deleted", INITIAL_CONTENT.substring(1), after); }
register(OperationType.ROBOT_CREATE_WAVELET, CreateWaveletService.create()); register(OperationType.ROBOT_FETCH_WAVE, FetchWaveService.create()); register(OperationType.DOCUMENT_MODIFY, DocumentModifyService.create()); register(OperationType.ROBOT_SEARCH, injector.getInstance(SearchService.class)); register(OperationType.WAVELET_SET_TITLE, WaveletSetTitleService.create());
public void testDelete() throws Exception { OperationRequest operation = operationRequest(OperationType.DOCUMENT_MODIFY, rootBlipId, Parameter.of(ParamsProperty.MODIFY_ACTION, new DocumentModifyAction(ModifyHow.DELETE, NO_VALUES, NO_ANNOTATION_KEY, NO_ELEMENTS, NO_BUNDLED_ANNOTATIONS, false)), Parameter.of(ParamsProperty.INDEX, CONTENT_START_TEXT)); service.execute(operation, helper.getContext(), ALEX); // Cut off the /n String after = getApiView().apiContents().substring(1); assertEquals("First character should be deleted", INITIAL_CONTENT.substring(1), after); }
register(OperationType.ROBOT_CREATE_WAVELET, CreateWaveletService.create()); register(OperationType.ROBOT_FETCH_WAVE, FetchWaveService.create()); register(OperationType.DOCUMENT_MODIFY, DocumentModifyService.create()); register(OperationType.ROBOT_SEARCH, injector.getInstance(SearchService.class)); register(OperationType.WAVELET_SET_TITLE, WaveletSetTitleService.create());
public void testReplace() throws Exception { String replacement = "replacedText"; OperationRequest operation = operationRequest(OperationType.DOCUMENT_MODIFY, rootBlipId, Parameter.of(ParamsProperty.MODIFY_ACTION, new DocumentModifyAction(ModifyHow.REPLACE, Collections.singletonList(replacement), NO_ANNOTATION_KEY, NO_ELEMENTS, NO_BUNDLED_ANNOTATIONS, false)), Parameter.of(ParamsProperty.RANGE, new Range(CONTENT_START_TEXT, CONTENT_START_TEXT + INITIAL_CONTENT.length()))); service.execute(operation, helper.getContext(), ALEX); // Cut off the /n String after = getApiView().apiContents().substring(1); assertEquals("The entire text should be replaced", replacement, after); }
@SuppressWarnings("deprecation") @Inject OperationServiceRegistryImpl(NotifyOperationService notifyOpService) { super(); // Register all the OperationProviders register(OperationType.ROBOT_NOTIFY, notifyOpService); register(OperationType.ROBOT_NOTIFY_CAPABILITIES_HASH, notifyOpService); register(OperationType.WAVELET_ADD_PARTICIPANT_NEWSYNTAX, ParticipantServices.create()); register(OperationType.WAVELET_APPEND_BLIP, BlipOperationServices.create()); register(OperationType.WAVELET_REMOVE_PARTICIPANT_NEWSYNTAX, ParticipantServices.create()); register(OperationType.BLIP_CONTINUE_THREAD, BlipOperationServices.create()); register(OperationType.BLIP_CREATE_CHILD, BlipOperationServices.create()); register(OperationType.BLIP_DELETE, BlipOperationServices.create()); register(OperationType.DOCUMENT_APPEND_INLINE_BLIP, BlipOperationServices.create()); register(OperationType.DOCUMENT_APPEND_MARKUP, BlipOperationServices.create()); register(OperationType.DOCUMENT_INSERT_INLINE_BLIP, BlipOperationServices.create()); register(OperationType.DOCUMENT_INSERT_INLINE_BLIP_AFTER_ELEMENT, BlipOperationServices.create()); register(OperationType.WAVELET_CREATE, CreateWaveletService.create()); register(OperationType.DOCUMENT_MODIFY, DocumentModifyService.create()); register(OperationType.WAVELET_SET_TITLE, WaveletSetTitleService.create()); register(OperationType.ROBOT_FOLDER_ACTION, FolderActionService.create()); } }
public void testReplace() throws Exception { String replacement = "replacedText"; OperationRequest operation = operationRequest(OperationType.DOCUMENT_MODIFY, rootBlipId, Parameter.of(ParamsProperty.MODIFY_ACTION, new DocumentModifyAction(ModifyHow.REPLACE, Collections.singletonList(replacement), NO_ANNOTATION_KEY, NO_ELEMENTS, NO_BUNDLED_ANNOTATIONS, false)), Parameter.of(ParamsProperty.RANGE, new Range(CONTENT_START_TEXT, CONTENT_START_TEXT + INITIAL_CONTENT.length()))); service.execute(operation, helper.getContext(), ALEX); // Cut off the /n String after = getApiView().apiContents().substring(1); assertEquals("The entire text should be replaced", replacement, after); }
Parameter.of(ParamsProperty.INDEX, CONTENT_START_TEXT)); service.execute(operation, helper.getContext(), ALEX);
public void testFailOnMultipleWhereParams() throws Exception { OperationRequest operation = operationRequest(OperationType.DOCUMENT_MODIFY, rootBlipId, Parameter.of(ParamsProperty.MODIFY_ACTION, new DocumentModifyAction()), Parameter.of(ParamsProperty.RANGE, new Range(0, 1)), Parameter.of(ParamsProperty.INDEX, 0)); try { service.execute(operation, helper.getContext(), ALEX); fail("Expected InvalidRequestException"); } catch (InvalidRequestException e) { // expected } }
Parameter.of(ParamsProperty.INDEX, CONTENT_START_TEXT)); service.execute(operation, helper.getContext(), ALEX);
public void testFailOnMultipleWhereParams() throws Exception { OperationRequest operation = operationRequest(OperationType.DOCUMENT_MODIFY, rootBlipId, Parameter.of(ParamsProperty.MODIFY_ACTION, new DocumentModifyAction()), Parameter.of(ParamsProperty.RANGE, new Range(0, 1)), Parameter.of(ParamsProperty.INDEX, 0)); try { service.execute(operation, helper.getContext(), ALEX); fail("Expected InvalidRequestException"); } catch (InvalidRequestException e) { // expected } }
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 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)); }