Examples of ObservableConversation


Examples of org.waveprotocol.wave.model.conversation.ObservableConversation

        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.wave.model.conversation.ObservableConversation

    blipData.setBlipId(TEMP_BLIP_ID);
  }

  public void testAddParticipant() throws Exception {
    OperationContextImpl context = helper.getContext();
    ObservableConversation conversation =
        context.openConversation(WAVE_ID, WAVELET_ID, ROBOT).getRoot();
    String rootBlipId = ConversationUtil.getRootBlipId(conversation);

    // Confirm alex is not on wave prior to operation.
    Set<ParticipantId> participants = conversation.getParticipantIds();
    assertFalse("Alex should not be a participant on wavelet prior to operation to add him.",
        participants.contains(ALEX));

    OperationRequest operation =
        operationRequest(OperationType.WAVELET_ADD_PARTICIPANT_NEWSYNTAX, rootBlipId,
            Parameter.of(ParamsProperty.PARTICIPANT_ID,ALEX.getAddress()));

    service.execute(operation, context, ROBOT);

    JsonRpcResponse response = context.getResponse(OPERATION_ID);
    assertFalse("Add Participant generated error in service execution.", response.isError());

    // Verify Alex is now a participant on the wave.
    participants = conversation.getParticipantIds();
    assertTrue("Alex should now be a participant on the wavelet.", participants.contains(ALEX));
  }
View Full Code Here

Examples of org.waveprotocol.wave.model.conversation.ObservableConversation

    assertTrue("Alex should now be a participant on the wavelet.", participants.contains(ALEX));
  }

  public void testAddThrowsOnDuplicateParticipant() throws Exception {
    OperationContextImpl context = helper.getContext();
    ObservableConversation conversation =
        context.openConversation(WAVE_ID, WAVELET_ID, ROBOT).getRoot();
    String rootBlipId = ConversationUtil.getRootBlipId(conversation);

    // Confirm robot is on wave prior to operation to re-add it.
    Set<ParticipantId> participants = conversation.getParticipantIds();
    assertTrue("Robot should be a participant on wavelet prior to test operation to add it.",
        participants.contains(ROBOT));

    OperationRequest operation =
        operationRequest(OperationType.WAVELET_ADD_PARTICIPANT_NEWSYNTAX, rootBlipId,
View Full Code Here

Examples of org.waveprotocol.wave.model.conversation.ObservableConversation

    }
  }

  public void testRemoveParticipant() throws Exception {
    OperationContextImpl context = helper.getContext();
    ObservableConversation conversation =
        context.openConversation(WAVE_ID, WAVELET_ID, ROBOT).getRoot();
    String rootBlipId = ConversationUtil.getRootBlipId(conversation);

    // Confirm alex is not on wave prior to operation.
    Set<ParticipantId> participants = conversation.getParticipantIds();
    assertFalse("Alex should not be a participant on wavelet prior to operation to add him.",
        participants.contains(ALEX));

    OperationRequest operation =
        new OperationRequest(OperationType.WAVELET_ADD_PARTICIPANT_NEWSYNTAX.method(), OPERATION_ID,
            s(WAVE_ID), s(WAVELET_ID), rootBlipId, Parameter.of(ParamsProperty.PARTICIPANT_ID,
                ALEX.getAddress()));

    service.execute(operation, context, ROBOT);

    // Verify Alex is now a participant on the wave.
    participants = conversation.getParticipantIds();
    assertTrue("Alex should now be a participant on the wavelet.", participants.contains(ALEX));

    // Attempt to remove Alex.
    OperationRequest operation2 =
        operationRequest(OperationType.WAVELET_REMOVE_PARTICIPANT_NEWSYNTAX, OPERATION2_ID,
            rootBlipId, Parameter.of(ParamsProperty.PARTICIPANT_ID, ALEX.getAddress()));

    service.execute(operation2, context, ROBOT);

    // Verify Alex is no longer a participant on the wave.
    participants = conversation.getParticipantIds();
    assertFalse("Alex should no longer be a participant on the wavelet.",
        participants.contains(ALEX));
  }
View Full Code Here

Examples of org.waveprotocol.wave.model.conversation.ObservableConversation

        participants.contains(ALEX));
  }

  public void testRemoveThrowsOnNonWaveletParticipant() throws Exception {
    OperationContextImpl context = helper.getContext();
    ObservableConversation conversation =
        context.openConversation(WAVE_ID, WAVELET_ID, ROBOT).getRoot();
    String rootBlipId = ConversationUtil.getRootBlipId(conversation);

    // Confirm alex is not on wave prior to operation.
    Set<ParticipantId> participants = conversation.getParticipantIds();
    assertFalse("Alex should not be a participant on wavelet prior to operation to add him.",
        participants.contains(ALEX));

    OperationRequest operation =
        operationRequest(OperationType.WAVELET_REMOVE_PARTICIPANT_NEWSYNTAX, rootBlipId,
View Full Code Here

Examples of org.waveprotocol.wave.model.conversation.ObservableConversation

    }
  }

  public void testInvalidParticipantAddress() throws Exception {
    OperationContextImpl context = helper.getContext();
    ObservableConversation conversation =
        context.openConversation(WAVE_ID, WAVELET_ID, ROBOT).getRoot();
    String rootBlipId = ConversationUtil.getRootBlipId(conversation);

    OperationRequest operation =
        operationRequest(OperationType.WAVELET_ADD_PARTICIPANT_NEWSYNTAX, rootBlipId,
View Full Code Here

Examples of org.waveprotocol.wave.model.conversation.ObservableConversation

    verify(doc).startDiffSuppression();
    verify(doc, never()).stopDiffSuppression();
  }

  public void testFreshBecomingReadStopsSuppression() {
    ObservableConversation conv = wave.createRoot();
    ObservableConversationBlip root = conv.getRootThread().appendBlip();

    MockDoc doc = mock(MockDoc.class);
    when(doc.isCompleteDiff()).thenReturn(true, false);
    when(documents.get(root)).thenReturn(doc);
    target.install();
View Full Code Here

Examples of org.waveprotocol.wave.model.conversation.ObservableConversation

    verify(doc).startDiffSuppression();
    verify(doc).stopDiffSuppression();
  }

  public void testReadBecomingReadClearsDiffsButNotSuppression() {
    ObservableConversation conv = wave.createRoot();
    ObservableConversationBlip root = conv.getRootThread().appendBlip();

    MockDoc doc = mock(MockDoc.class);
    when(doc.isCompleteDiff()).thenReturn(false);
    when(documents.get(root)).thenReturn(doc);
    target.install();
View Full Code Here

Examples of org.waveprotocol.wave.model.conversation.ObservableConversation

  public void execute(OperationRequest operation, OperationContext context,
      ParticipantId participant) throws InvalidRequestException {

    // Get the conversation wavelet. If participant performing operation is not
    // a member of wavelet, InvalidRequestException is thrown by this method.
    ObservableConversation conversation =
        context.openConversation(operation, participant).getRoot();

    // Get participant operation is being performed on.
    String paramParticipant =
        OperationUtil.getRequiredParameter(operation, ParamsProperty.PARTICIPANT_ID);

    ParticipantId targetParticipant;
    try {
      targetParticipant = ParticipantId.of(paramParticipant);
    } catch (InvalidParticipantAddress e) {
      String message = "Target ParticipantId " + paramParticipant + " is not " + "valid";
      LOG.info(message);
      throw new InvalidRequestException(message);
    }

    String rootBlipId = ConversationUtil.getRootBlipId(conversation);

    // Create generic event (defined by operation type) that will be processed
    // by the context.
    Event event;

    // Set up participant containers.
    List<String> participantsAdded = Lists.newArrayList();
    List<String> participantsRemoved = Lists.newArrayList();

    OperationType type = OperationUtil.getOperationType(operation);
    switch (type) {
      case WAVELET_ADD_PARTICIPANT_NEWSYNTAX:
        // Make sure targetParticipant is not already member.
        if (conversation.getParticipantIds().contains(targetParticipant)) {
          String message = targetParticipant.getAddress() + " is already a " + "member of wavelet";
          LOG.info(message);
          throw new InvalidRequestException(message, operation);
        }

        // Add participant to conversation and send event.
        conversation.addParticipant(targetParticipant);
        participantsAdded.add(targetParticipant.getAddress());
        event =
            new WaveletParticipantsChangedEvent(null, null, participant.getAddress(),
                System.currentTimeMillis(), rootBlipId, participantsAdded, participantsRemoved);
        break;
      case WAVELET_REMOVE_PARTICIPANT_NEWSYNTAX:
        // Make sure targetParticipant is already member.
        if (!conversation.getParticipantIds().contains(targetParticipant)) {
          // Not a member, throw invalid request.
          String message = targetParticipant.getAddress() + " is not a " + "member of wavelet";
          LOG.info(message);
          throw new InvalidRequestException(message, operation);
        }

        // Remove participant and send event.
        conversation.removeParticipant(targetParticipant);
        participantsRemoved.add(targetParticipant.getAddress());

        event =
            new WaveletParticipantsChangedEvent(null, null, participant.getAddress(),
                System.currentTimeMillis(), rootBlipId, participantsAdded, participantsRemoved);
View Full Code Here

Examples of org.waveprotocol.wave.model.conversation.ObservableConversation

            ParticipationHelper.DEFAULT, executor, SilentOperationSink.VOID);

    // Make a conversation with an empty root blip
    WaveletBasedConversation.makeWaveletConversational(wavelet);
    ConversationUtil conversationUtil = new ConversationUtil(FakeIdGenerator.create());
    ObservableConversation conversation = conversationUtil.buildConversation(wavelet).getRoot();
    conversation.getRootThread().appendBlip();

    context = new OperationContextImpl(waveletProvider, converter, conversationUtil);
    context.putWavelet(waveletName.waveId, waveletName.waveletId,
        new RobotWaveletData(waveletData, HASH_FACTORY.createVersionZero(waveletName)));
  }
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.