private static void assertEquals(Event expected, Event actual) { assertEquals(expected.getType(), actual.getType()); assertEquals(expected.getWavelet(), actual.getWavelet()); assertEquals(expected.getModifiedBy(), actual.getModifiedBy()); assertEquals(expected.getTimestamp(), actual.getTimestamp()); assertEquals(expected.getBlip(), actual.getBlip()); assertEquals(expected.getBundle(), actual.getBundle()); } }
/** * Checks whether the event should be filtered out. It can happen * if the robot received several deltas where in some delta it is added to * the wavelet but it didn't receive the WAVELET_SELF_ADDED event yet. * Or if robot already received WAVELET_SELF_REMOVED * event - then it should not receive events after that. * * @param event the event to filter. * @return true if the event should be filtered out */ protected boolean isEventFilteredOut(Event event) { boolean isEventSuspensionOveriden = false; if (event.getType().equals(EventType.WAVELET_SELF_REMOVED)) { // Stop processing events. isEventProcessingSuspended = true; // Allow robot receive WAVELET_SELF_REMOVED event, but suspend after that. isEventSuspensionOveriden = true; } if (event.getType().equals(EventType.WAVELET_SELF_ADDED)) { // Start processing events. isEventProcessingSuspended = false; } if ((isEventProcessingSuspended && !isEventSuspensionOveriden) || event.getModifiedBy().equals(robotName.toParticipantAddress())) { // Robot was removed from wave or this is self generated event. return true; } return false; }
result.addProperty(TYPE, event.getType().name()); result.addProperty(MODIFIED_BY, event.getModifiedBy()); result.addProperty(TIMESTAMP, event.getTimestamp()); result.addProperty(TIMESTAMP, event.getTimestamp());
/** * Return whether the lookingFor event is contained in this bundle. */ public boolean hasEvent(EventType eventType) { for (Event event : events) { if (event.getType() == eventType) { return true; } } return false; }
/** * Checks whether a button in a blip was clicked or not. This method will * reset the state of the button to be "unclicked" at the end of the method * call. * * @param events A list of events received from Google Wave that needs to be * checked whether it contains form button clicked event or not. * @return true If the user just clicked on the button. */ public boolean isButtonClicked(List<Event> events) { for (Event event : events) { if (event.getType() == EventType.FORM_BUTTON_CLICKED && LOGIN_BUTTON_ID.equals(FormButtonClickedEvent.as(event).getButtonName())) { return true; } } return false; } }
private static void assertEquals(Event expected, Event actual) { assertEquals(expected.getType(), actual.getType()); assertEquals(expected.getWavelet(), actual.getWavelet()); assertEquals(expected.getModifiedBy(), actual.getModifiedBy()); assertEquals(expected.getTimestamp(), actual.getTimestamp()); assertEquals(expected.getBlip(), actual.getBlip()); assertEquals(expected.getBundle(), actual.getBundle()); } }
/** * Checks whether all events generated are in the capabilities map. */ private void checkAllEventsAreInCapabilites(EventMessageBundle messages, Map<EventType, Capability> capabilities) { for (Event event : messages.getEvents()) { if (!capabilities.containsKey(event.getType())) { fail("Generated event of type" + event.getType() + " which is not in the capabilities"); } } } }
/** * Checks whether all events generated are in the capabilities map. */ private void checkAllEventsAreInCapabilites(EventMessageBundle messages, Map<EventType, Capability> capabilities) { for (Event event : messages.getEvents()) { if (!capabilities.containsKey(event.getType())) { fail("Generated event of type" + event.getType() + " which is not in the capabilities"); } } } }
/** * Checks whether events of the given types were put in the bundle. */ private void checkEventTypeWasGenerated(EventMessageBundle messages, EventType... types) { Set<EventType> eventsTypeSet = Sets.newHashSet(); for (EventType eventType : types) { eventsTypeSet.add(eventType); } for (Event event : messages.getEvents()) { if (eventsTypeSet.contains(event.getType())) { eventsTypeSet.remove(event.getType()); } } if (eventsTypeSet.size() != 0) { fail("Event of type " + eventsTypeSet.iterator().next() + " has not been generated"); } }
/** * Checks whether events of the given types were put in the bundle. */ private void checkEventTypeWasGenerated(EventMessageBundle messages, EventType... types) { Set<EventType> eventsTypeSet = Sets.newHashSet(); for (EventType eventType : types) { eventsTypeSet.add(eventType); } for (Event event : messages.getEvents()) { if (eventsTypeSet.contains(event.getType())) { eventsTypeSet.remove(event.getType()); } } if (eventsTypeSet.size() != 0) { fail("Event of type " + eventsTypeSet.iterator().next() + " has not been generated"); } }
Capability capability = capabilities.get(event.getType()); List<Context> contexts; if (capability == null) {
@Override public void processEvent(OperationRequest operation, Event event) throws InvalidRequestException { // Create JSON-RPC error response. if (event.getType() == EventType.OPERATION_ERROR) { constructErrorResponse(operation, OperationErrorEvent.as(event).getMessage()); return; } // Create JSON-RPC success response. try { constructResponse(operation, EventSerializer.extractPropertiesToParamsPropertyMap(event)); } catch (EventSerializationException e) { LOG.severe("Internal Error occurred, when serializing events", e); throw new InvalidRequestException("Unable to serialize events", operation); } }
switch (event.getType()) { case ANNOTATED_TEXT_CHANGED: onAnnotatedTextChanged(AnnotatedTextChangedEvent.as(event));