@Override public void onBlipAdded(ObservableConversationBlip blip) { if (capabilities.containsKey(EventType.WAVELET_BLIP_CREATED)) { String rootBlipId = ConversationUtil.getRootBlipId(conversation); WaveletBlipCreatedEvent event = new WaveletBlipCreatedEvent( null, null, deltaAuthor.getAddress(), deltaTimestamp, rootBlipId, blip.getId()); addEvent(event, capabilities, rootBlipId, messages); } }
@Capability(contexts = {Context.SELF, Context.SIBLINGS}) @Override public void onWaveletBlipCreated(WaveletBlipCreatedEvent event) { Blip blip = event.getNewBlip(); if (!isShadowBlip(blip)) { createShadowBlip(blip); } }
public void testGenerateWaveletBlipCreatedEvent() throws Exception { ObservableConversationView conversation = conversationUtil.buildConversation(wavelet); ObservableConversationBlip newBlip = conversation.getRoot().getRootThread().appendBlip(); EventMessageBundle messages = generateAndCheckEvents(EventType.WAVELET_BLIP_CREATED); assertEquals("Expected one event", 1, messages.getEvents().size()); WaveletBlipCreatedEvent event = WaveletBlipCreatedEvent.as(messages.getEvents().get(0)); assertEquals("Expected the same id as the new blip", newBlip.getId(), event.getNewBlipId()); }
break; case WAVELET_BLIP_CREATED: onWaveletBlipCreated(WaveletBlipCreatedEvent.as(event)); break; case WAVELET_BLIP_REMOVED:
public void testGenerateWaveletBlipCreatedEvent() throws Exception { ObservableConversationView conversation = conversationUtil.buildConversation(wavelet); ObservableConversationBlip newBlip = conversation.getRoot().getRootThread().appendBlip(); EventMessageBundle messages = generateAndCheckEvents(EventType.WAVELET_BLIP_CREATED); assertEquals("Expected one event", 1, messages.getEvents().size()); WaveletBlipCreatedEvent event = WaveletBlipCreatedEvent.as(messages.getEvents().get(0)); assertEquals("Expected the same id as the new blip", newBlip.getId(), event.getNewBlipId()); }
/** * Processes a {@link WaveletBlipCreatedEvent} and puts it into the context. * * @param operation the operation that has been performed * @param context the context of the operation. * @param participant the participant performing the operation. * @param conversation the conversation to which the new blip was added * @param newBlip the newly created blip. * @throws InvalidRequestException if the event could not be processed. */ private void processBlipCreatedEvent(OperationRequest operation, OperationContext context, ParticipantId participant, ObservableConversation conversation, ConversationBlip newBlip) throws InvalidRequestException { WaveletBlipCreatedEvent event = new WaveletBlipCreatedEvent(null, null, participant.getAddress(), System.currentTimeMillis(), ConversationUtil.getRootBlipId(conversation), newBlip.getId()); context.processEvent(operation, event); }
public void testProcessEvent() throws Exception { // A randomly selected non-error event Event event = new WaveletBlipCreatedEvent(null, null, USERNAME, 0L, "root", "newBlip"); operationContext.processEvent(request, event); JsonRpcResponse response = operationContext.getResponse(request.getId()); assertFalse("Expected non-error response", response.isError()); assertEquals("Expected operation id not to change", OPERATION_ID, response.getId()); }
public void testProcessEvent() throws Exception { // A randomly selected non-error event Event event = new WaveletBlipCreatedEvent(null, null, USERNAME, 0L, "root", "newBlip"); operationContext.processEvent(request, event); JsonRpcResponse response = operationContext.getResponse(request.getId()); assertFalse("Expected non-error response", response.isError()); assertEquals("Expected operation id not to change", OPERATION_ID, response.getId()); }