@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 static BlipOperationServices create() { return new BlipOperationServices(); } }
switch (type) { case BLIP_CONTINUE_THREAD: continueThread(operation, context, participant, conversation); break; case BLIP_CREATE_CHILD: createChild(operation, context, participant, conversation); break; case WAVELET_APPEND_BLIP: appendBlip(operation, context, participant, conversation); break; case DOCUMENT_APPEND_INLINE_BLIP: appendInlineBlip(operation, context, participant, wavelet, conversation); break; case DOCUMENT_APPEND_MARKUP: appendMarkup(operation, context, participant, wavelet, conversation); break; case DOCUMENT_INSERT_INLINE_BLIP: insertInlineBlip(operation, context, participant, wavelet, conversation); break; case DOCUMENT_INSERT_INLINE_BLIP_AFTER_ELEMENT: insertInlineBlipAfterElement(operation, context, participant, wavelet, conversation); break; case BLIP_DELETE: delete(operation, context, participant, conversation); break; default:
public void testAppendBlip() throws Exception { OperationRequest operation = operationRequest(OperationType.WAVELET_APPEND_BLIP, Parameter.of(ParamsProperty.BLIP_DATA, blipData)); OperationContextImpl context = helper.getContext(); service.execute(operation, context, ALEX); JsonRpcResponse response = context.getResponse(OPERATION_ID); assertFalse(response.isError()); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); ConversationBlip newBlip = checkAndGetNewBlip(context, conversation, response); Iterator<? extends ObservableConversationBlip> it = conversation.getRootThread().getBlips().iterator(); it.next(); // skip, root assertEquals("New blip should be the second blip in the root thread", newBlip, it.next()); }
public void testAppendBlip() throws Exception { OperationRequest operation = operationRequest(OperationType.WAVELET_APPEND_BLIP, Parameter.of(ParamsProperty.BLIP_DATA, blipData)); OperationContextImpl context = helper.getContext(); service.execute(operation, context, ALEX); JsonRpcResponse response = context.getResponse(OPERATION_ID); assertFalse(response.isError()); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); ConversationBlip newBlip = checkAndGetNewBlip(context, conversation, response); Iterator<? extends ObservableConversationBlip> it = conversation.getRootThread().getBlips().iterator(); it.next(); // skip, root assertEquals("New blip should be the second blip in the root thread", newBlip, it.next()); }
public void testContinueThread() throws Exception { OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); // Append a random blip to check that we actually append to the end of this // thread. conversation.getRootThread().appendBlip(); // Append to continue the thread of the root blip String rootBlipId = ConversationUtil.getRootBlipId(conversation); OperationRequest operation = operationRequest(OperationType.BLIP_CONTINUE_THREAD, 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 ObservableConversationBlip> it = conversation.getRootThread().getBlips().iterator(); it.next(); // skip, root it.next(); // skip, first reply assertEquals("New blip should be the third blip in the root thread", newBlip, it.next()); }
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.ROBOT_CREATE_WAVELET, CreateWaveletService.create()); register(OperationType.ROBOT_FETCH_WAVE, FetchWaveService.create());
public void testContinueThread() throws Exception { OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); // Append a random blip to check that we actually append to the end of this // thread. conversation.getRootThread().appendBlip(); // Append to continue the thread of the root blip String rootBlipId = ConversationUtil.getRootBlipId(conversation); OperationRequest operation = operationRequest(OperationType.BLIP_CONTINUE_THREAD, 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 ObservableConversationBlip> it = conversation.getRootThread().getBlips().iterator(); it.next(); // skip, root it.next(); // skip, first reply assertEquals("New blip should be the third blip in the root thread", newBlip, it.next()); }
register(OperationType.ROBOT_NOTIFY_CAPABILITIES_HASH, DoNothingService.create()); 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.ROBOT_CREATE_WAVELET, CreateWaveletService.create()); register(OperationType.ROBOT_FETCH_WAVE, FetchWaveService.create());
public void testDeleteBlip() throws Exception { OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); // Delete the root blip String rootBlipId = ConversationUtil.getRootBlipId(conversation); OperationRequest operation = operationRequest(OperationType.BLIP_DELETE, rootBlipId); service.execute(operation, context, ALEX); JsonRpcResponse response = context.getResponse(OPERATION_ID); assertFalse(response.isError()); assertNull("Blip should have been deleted", conversation.getBlip(rootBlipId)); }
@Override protected void setUp() { service = BlipOperationServices.create(); helper = new OperationServiceHelper(WAVELET_NAME, ALEX); // BlipData constructor is broken, it doesn't set the blipId passed in the // constructor blipData = new BlipData(s(WAVE_ID), s(WAVELET_ID), TEMP_BLIP_ID, NEW_BLIP_CONTENT); blipData.setBlipId(TEMP_BLIP_ID); }
public void testDeleteBlip() throws Exception { OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); // Delete the root blip String rootBlipId = ConversationUtil.getRootBlipId(conversation); OperationRequest operation = operationRequest(OperationType.BLIP_DELETE, rootBlipId); service.execute(operation, context, ALEX); JsonRpcResponse response = context.getResponse(OPERATION_ID); assertFalse(response.isError()); assertNull("Blip should have been deleted", conversation.getBlip(rootBlipId)); }
@Override protected void setUp() { service = BlipOperationServices.create(); helper = new OperationServiceHelper(WAVELET_NAME, ALEX); // BlipData constructor is broken, it doesn't set the blipId passed in the // constructor blipData = new BlipData(s(WAVE_ID), s(WAVELET_ID), TEMP_BLIP_ID, NEW_BLIP_CONTENT); blipData.setBlipId(TEMP_BLIP_ID); }
public void testAppendBadMarkup() throws Exception { // Set markup with different end tag. String markup = "<custom>"+NEW_BLIP_CONTENT+"</diffcustom>"; OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); // Append the custom markup to the newly created blip. ConversationBlip markupBlip = conversation.getRootThread().appendBlip(); OperationRequest operation = operationRequest(OperationType.DOCUMENT_APPEND_MARKUP, markupBlip.getId(), Parameter.of(ParamsProperty.CONTENT, markup)); try { service.execute(operation, context, ALEX); fail("Bad Markup should have generated error in service execution."); } catch(IllegalArgumentException e) { // Good. } }
public void testAppendBadMarkup() throws Exception { // Set markup with different end tag. String markup = "<custom>"+NEW_BLIP_CONTENT+"</diffcustom>"; OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); // Append the custom markup to the newly created blip. ConversationBlip markupBlip = conversation.getRootThread().appendBlip(); OperationRequest operation = operationRequest(OperationType.DOCUMENT_APPEND_MARKUP, markupBlip.getId(), Parameter.of(ParamsProperty.CONTENT, markup)); try { service.execute(operation, context, ALEX); fail("Bad Markup should have generated error in service execution."); } catch(IllegalArgumentException e) { // Good. } }
public void testCreateChild() throws Exception { OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); // Append a random blip to check that we actually make a new child blip conversation.getRootThread().appendBlip(); // Create a child to the rootblip String rootBlipId = ConversationUtil.getRootBlipId(conversation); OperationRequest operation = operationRequest(OperationType.BLIP_CREATE_CHILD, 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 ObservableConversationThread> it = conversation.getRootThread().getFirstBlip().getReplyThreads().iterator(); assertEquals("New blip should be the first blip in the first reply thread", it.next().getFirstBlip(), newBlip); }
public void testCreateChild() throws Exception { OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); // Append a random blip to check that we actually make a new child blip conversation.getRootThread().appendBlip(); // Create a child to the rootblip String rootBlipId = ConversationUtil.getRootBlipId(conversation); OperationRequest operation = operationRequest(OperationType.BLIP_CREATE_CHILD, 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 ObservableConversationThread> it = conversation.getRootThread().getFirstBlip().getReplyThreads().iterator(); assertEquals("New blip should be the first blip in the first reply thread", it.next().getFirstBlip(), newBlip); }
public void testAppendCustomMarkup() throws Exception { String markup = "<custom>this is custom markup</custom>"; OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); // Append the custom markup to the newly created blip. ConversationBlip markupBlip = conversation.getRootThread().appendBlip(); OperationRequest operation = operationRequest(OperationType.DOCUMENT_APPEND_MARKUP, markupBlip.getId(), Parameter.of(ParamsProperty.CONTENT, markup)); service.execute(operation, context, ALEX); JsonRpcResponse response = context.getResponse(OPERATION_ID); assertFalse("CustomMarkup generated error in service execution.", response.isError()); // The xml in new blip should match custom markup. String actualContent = markupBlip.getContent().toXmlString(); assertTrue("Expected the new blip to contain the custom markup as specified in the " + "operation. actualcontent: " + actualContent, actualContent.contains(markup)); }
public void testAppendCustomMarkup() throws Exception { String markup = "<custom>this is custom markup</custom>"; OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot(); // Append the custom markup to the newly created blip. ConversationBlip markupBlip = conversation.getRootThread().appendBlip(); OperationRequest operation = operationRequest(OperationType.DOCUMENT_APPEND_MARKUP, markupBlip.getId(), Parameter.of(ParamsProperty.CONTENT, markup)); service.execute(operation, context, ALEX); JsonRpcResponse response = context.getResponse(OPERATION_ID); assertFalse("CustomMarkup generated error in service execution.", response.isError()); // The xml in new blip should match custom markup. String actualContent = markupBlip.getContent().toXmlString(); assertTrue("Expected the new blip to contain the custom markup as specified in the " + "operation. actualcontent: " + actualContent, actualContent.contains(markup)); }
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()); }