Package com.google.wave.api.impl

Examples of com.google.wave.api.impl.EventMessageBundle


    Map<String, Blip> blips = Maps.newHashMap();
    blips.put("blip123", blip);
    when(wavelet.getThread(anyString())).thenReturn(new BlipThread("rootThread", -1,
        Lists.<String>newArrayList("blip123"), blips));
   
    EventMessageBundle bundle = new EventMessageBundle("http://10.1.1.1",
        "http://wave-active-api.example.com");

    WaveletParticipantsChangedEvent expected = new WaveletParticipantsChangedEvent(wavelet,
        bundle, "mprasetya@google.com", 1l, "blip123", participantsAdded, participantsRemoved);
View Full Code Here


    Blip blip = mock(Blip.class);
    when(blip.getBlipId()).thenReturn("blip123");
    Wavelet wavelet = mock(Wavelet.class);
    when(wavelet.getBlip("blip123")).thenReturn(blip);
    EventMessageBundle bundle = new EventMessageBundle("http://10.1.1.1",
        "http://wave-active-api.example.com");

    BlipContributorsChangedEvent expected = new BlipContributorsChangedEvent(wavelet,
        bundle, "mprasetya@google.com", 1l, "blip123", contributorsAdded, contributorsRemoved);
View Full Code Here

    Blip blip = mock(Blip.class);
    when(blip.getBlipId()).thenReturn("blip123");
    Wavelet wavelet = mock(Wavelet.class);
    when(wavelet.getBlip("blip123")).thenReturn(blip);
    EventMessageBundle bundle = new EventMessageBundle("http://10.1.1.1",
        "http://wave-active-api.example.com");

    GadgetStateChangedEvent expected = new GadgetStateChangedEvent(wavelet, bundle,
        "mprasetya@google.com", 1l, "blip123", 5, oldState);
View Full Code Here

    assertEquals(expected.getOldState(),actual.getOldState());
  }

  public void refactor_testSerializeAndDeserializeOperationErrorEvent() throws Exception {
    Wavelet wavelet = mock(Wavelet.class);
    EventMessageBundle bundle = new EventMessageBundle("http://10.1.1.1",
        "http://wave-active-api.example.com");

    OperationErrorEvent expected = new OperationErrorEvent(wavelet, bundle,
        "foo@google.com", 123l, "op1", "Error!");
    Context context = new Context();
View Full Code Here

   *        WaveletData and BlipData.
   * @returns true if an event was generated, false otherwise
   */
  public EventMessageBundle generateEvents(WaveletAndDeltas waveletAndDeltas,
      Map<EventType, Capability> capabilities, EventDataConverter converter) {
    EventMessageBundle messages = new EventMessageBundle(robotName.toEmailAddress(), "");
    ObservableWaveletData snapshot =
        WaveletDataUtil.copyWavelet(waveletAndDeltas.getSnapshotBeforeDeltas());
    isEventProcessingSuspended = !snapshot.getParticipants().contains(robotId);

    if (robotName.hasProxyFor()) {
      // This robot is proxying so set the proxy field.
      messages.setProxyingFor(robotName.getProxyFor());
    }

    // Sending any operations will cause an exception.
    OpBasedWavelet wavelet =
        new OpBasedWavelet(snapshot.getWaveId(), snapshot,
            // This doesn't thrown an exception, the sinks will
            new BasicWaveletOperationContextFactory(null),
            ParticipationHelper.DEFAULT, SilentOperationSink.VOID, SilentOperationSink.VOID);

    ObservableConversation conversation = getRootConversation(wavelet);

    if (conversation == null) {
      return messages;
    }

    // Start listening
    EventGeneratingConversationListener conversationListener =
        new EventGeneratingConversationListener(conversation, capabilities, messages, robotName);
    conversation.addListener(conversationListener);
    EventGeneratingWaveletListener waveletListener =
        new EventGeneratingWaveletListener(capabilities);
    wavelet.addListener(waveletListener);

    Map<String, EventGeneratingDocumentHandler> docHandlers = Maps.newHashMap();
    try {
      for (TransformedWaveletDelta delta : waveletAndDeltas.getDeltas()) {
        // TODO(ljvderijk): Set correct timestamp and hashed version once
        // wavebus sends them along
        long timestamp = 0L;
        conversationListener.deltaBegin(delta.getAuthor(), timestamp);

        for (WaveletOperation op : delta) {
          // Check if we need to attach a doc handler.
          if ((op instanceof WaveletBlipOperation)) {
            attachDocHandler(conversation, op, docHandlers, capabilities, messages,
                delta.getAuthor(), timestamp);
          }
          op.apply(snapshot);
        }
        conversationListener.deltaEnd();
      }
    } catch (OperationException e) {
      throw new IllegalStateException("Operation failed to apply when generating events", e);
    } finally {
      conversation.removeListener(conversationListener);
      wavelet.removeListener(waveletListener);
      for (EventGeneratingDocumentHandler docHandler : docHandlers.values()) {
        docHandler.doc.removeListener(docHandler);
      }
    }

    if (messages.getEvents().isEmpty()) {
      // No events found, no need to resolve contexts
      return messages;
    }

    // Resolve the context of the bundle now that all events have been
View Full Code Here

        return;
      }
    }

    RobotCapabilities capabilities = account.getCapabilities();
    EventMessageBundle messages =
        eventGenerator.generateEvents(wavelet, capabilities.getCapabilitiesMap(),
            converterManager.getEventDataConverter(capabilities.getProtocolVersion()));

    if (messages.getEvents().isEmpty()) {
      // No events were generated, we are done
      LOG.info(robotName + ": no events were generated");
      return;
    }
View Full Code Here

    } else {
      OpBasedWavelet wavelet = context.openWavelet(operation, participant);
      ObservableConversation conversation =
          context.openConversation(operation, participant).getRoot();

      EventMessageBundle messages =
          mapWaveletToMessageBundle(context.getConverter(), participant, wavelet, conversation);

      String rootBlipId = ConversationUtil.getRootBlipId(conversation);
      String message = OperationUtil.getOptionalParameter(operation, ParamsProperty.MESSAGE);

      WaveletFetchedEvent event =
          new WaveletFetchedEvent(null, null, participant.getAddress(), System.currentTimeMillis(),
          message, rootBlipId, messages.getWaveletData(), messages.getBlipData(),
          messages.getThreads());

      context.processEvent(operation, event);
    }
  }
View Full Code Here

   * @param wavelet the wavelet to put in the bundle.
   * @param conversation the conversation to put in the bundle.
   */
  private EventMessageBundle mapWaveletToMessageBundle(EventDataConverter converter,
      ParticipantId participant, Wavelet wavelet, Conversation conversation) {
    EventMessageBundle messages = new EventMessageBundle(participant.getAddress(), "");
    WaveletData waveletData = converter.toWaveletData(wavelet, conversation, messages);
    messages.setWaveletData(waveletData);
    ContextResolver.addAllBlipsToEventMessages(messages, conversation, wavelet, converter);
    return messages;
  }
View Full Code Here

    super.setUp();
    Blips.init();

    conversation = makeConversation();
    wavelet = createMockWavelet(conversation);
    eventMessages = new EventMessageBundle("foo@appspot.com", "http://opensocial.example.com");
  }
View Full Code Here

    ConversationBlip blip = conversation.getRootThread().getFirstBlip();
    String replyThreadId = blip.addReplyThread(3).getId();

    EventDataConverterV22 converter = new EventDataConverterV22();
    EventMessageBundle eventMessageBundle = new EventMessageBundle(null, null);
    BlipData blipData = converter.toBlipData(blip, wavelet,
        eventMessageBundle);
    assertEquals(blip.getThread().getId(), blipData.getThreadId());
    assertEquals(Lists.newArrayList(replyThreadId), blipData.getReplyThreadIds());
    Map<String, BlipThread> threads = eventMessageBundle.getThreads();
    assertEquals(1, threads.size());
    assertEquals(1, threads.get(replyThreadId).getLocation());
  }
View Full Code Here

TOP

Related Classes of com.google.wave.api.impl.EventMessageBundle

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.