Package org.waveprotocol.box.server.robots

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


    WaveletProvider waveletProvider = mock(WaveletProvider.class);
    EventDataConverter converter = mock(EventDataConverter.class);
    ConversationUtil conversationUtil = mock(ConversationUtil.class);

    OperationContextImpl context =
        new OperationContextImpl(waveletProvider, converter, conversationUtil);

    operationService.execute(request, context, BOB);

    JsonRpcResponse response = context.getResponse(request.getId());
    assertFalse("Expected non error response", response.isError());
    assertTrue("Empty Response must be set", response.getData().isEmpty());
  }
View Full Code Here


  public void testFetchWave() throws Exception {
    String message = "A message";
    OperationRequest operation =
        operationRequest(OperationType.ROBOT_FETCH_WAVE,
            Parameter.of(ParamsProperty.MESSAGE, message));
    OperationContextImpl context = helper.getContext();
    WaveletProvider waveletProvider = helper.getWaveletProvider();
    when(waveletProvider.checkAccessPermission(WAVELET_NAME, ALEX)).thenReturn(true);

    service.execute(operation, context, ALEX);

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

    JsonRpcResponse response = context.getResponse(OPERATION_ID);
    assertNotNull("expected a response", response);
    assertFalse("expected a success response", response.isError());
    assertEquals("Expected the response to carry the message", message,
        response.getData().get(ParamsProperty.MESSAGE));
    assertNotNull("Expected the response to carry a wavelet",
View Full Code Here

  public void testFetchWaveWithMissingParamThrowsInvalidRequestException() throws Exception {
    // No wave id or wavelet id set.
    OperationRequest operation = new OperationRequest(OperationType.ROBOT_FETCH_WAVE.method(),
        OPERATION_ID);
    OperationContextImpl context = helper.getContext();

    try {
      service.execute(operation, context, ALEX);
      fail("Expected InvalidRequestException because params were not set");
    } catch (InvalidRequestException e) {
View Full Code Here

    blipData = new BlipData(s(WAVE_ID), s(WAVELET_ID), TEMP_BLIP_ID, NEW_BLIP_CONTENT);
    blipData.setBlipId(TEMP_BLIP_ID);
  }

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

    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

  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

  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

  }

  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

   */
  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

    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

TOP

Related Classes of org.waveprotocol.box.server.robots.OperationContextImpl

Copyright © 2018 www.massapicom. 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.