Examples of OperationContextImpl


Examples of org.waveprotocol.box.server.robots.OperationContextImpl

    it.next(); // skip, first reply
    assertEquals("New blip should be the third blip in the root thread", newBlip, it.next());
  }

  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 =
View Full Code Here

Examples of org.waveprotocol.box.server.robots.OperationContextImpl

  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
View Full Code Here

Examples of org.waveprotocol.box.server.robots.OperationContextImpl

  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,
View Full Code Here

Examples of org.waveprotocol.box.server.robots.OperationContextImpl

  }

  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 " +
View Full Code Here

Examples of org.waveprotocol.box.server.robots.OperationContextImpl

   */
  public void testAppendLineMarkup() throws Exception {
    // Just insert text. should create <line></line>Text.
    String markup = NEW_BLIP_CONTENT;

    OperationContextImpl context = helper.getContext();
    ObservableConversation conversation =
        context.openConversation(WAVE_ID, WAVELET_ID, ALEX).getRoot();

    // Append the text markup to the newly created blip.
    DocInitialization blipInitContent = new DocInitializationBuilder().build();
    ConversationBlip markupBlip = conversation.getRootThread().appendBlip(blipInitContent);

    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("LineMarkup generated error in service execution.", response.isError());

    // The output should now include the default <line/> element.
    String lineContent = markupBlip.getContent().toXmlString();
    assertTrue("Expected the blip to append the default wave <line/> element. " +
View Full Code Here

Examples of org.waveprotocol.box.server.robots.OperationContextImpl

    assertTrue("Expected the blip to append the default wave <line/> element. " +
        "actual content: " + lineContent, lineContent.contains("<line/>"+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 =
View Full Code Here

Examples of org.waveprotocol.box.server.robots.OperationContextImpl

    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 =
View Full Code Here

Examples of org.waveprotocol.box.server.robots.OperationContextImpl

    assertEquals("The inline reply was not located where specified", insertAtXmlLocation,
        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
View Full Code Here

Examples of org.waveprotocol.box.server.robots.OperationContextImpl

    assertEquals("The inline reply was not located where specified", it.next().getLocation() + 2,
        it.next().getLocation());
  }

  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));
  }
View Full Code Here

Examples of org.waveprotocol.box.server.robots.OperationContextImpl

    operationRegistry = mock(OperationServiceRegistry.class);
    ConversationUtil conversationUtil = mock(ConversationUtil.class);
    converter = mock(EventDataConverter.class);

    operation = new OperationRequest("wavelet.fetch", "op1", s(WAVE_ID), s(WAVELET_ID));
    context = new OperationContextImpl(waveletProvider, converter, conversationUtil);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.