public void refactor_testSerializeAndDeserializeWaveletEvent() throws Exception { List<String> participantsAdded = new ArrayList<String>(); participantsAdded.add("foo@google.com"); participantsAdded.add("bar@google.com"); List<String> participantsRemoved = new ArrayList<String>(); participantsRemoved.add("baz@google.com"); Blip blip = mock(Blip.class); when(blip.getBlipId()).thenReturn("blip123"); Wavelet wavelet = mock(Wavelet.class); when(wavelet.getBlip("blip123")).thenReturn(blip); 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); Context context = new Context(); Event actualEvent = EventSerializer.deserialize(wavelet, bundle, EventSerializer.serialize(expected, context), context); WaveletParticipantsChangedEvent actual = WaveletParticipantsChangedEvent.as(actualEvent); assertEquals(expected, actual); assertEquals(expected.getParticipantsAdded(), actual.getParticipantsAdded()); assertEquals(expected.getParticipantsRemoved(), actual.getParticipantsRemoved()); }
public void testGenerateWaveletParticipantsChangedEventOnAdd() throws Exception { wavelet.addParticipant(BOB); EventMessageBundle messages = generateAndCheckEvents(EventType.WAVELET_PARTICIPANTS_CHANGED); assertTrue("Only expected one event", messages.getEvents().size() == 1); WaveletParticipantsChangedEvent event = WaveletParticipantsChangedEvent.as(messages.getEvents().get(0)); assertTrue("Bob should be added", event.getParticipantsAdded().contains(BOB.getAddress())); }
public void testGenerateWaveletParticipantsChangedEventOnRemove() throws Exception { wavelet.removeParticipant(ALEX); EventMessageBundle messages = generateAndCheckEvents(EventType.WAVELET_PARTICIPANTS_CHANGED); assertEquals("Expected one event", 1, messages.getEvents().size()); WaveletParticipantsChangedEvent event = WaveletParticipantsChangedEvent.as(messages.getEvents().get(0)); assertTrue( "Alex should be removed", event.getParticipantsRemoved().contains(ALEX.getAddress())); }
/** * Generates the events that are collected over the span of one delta. */ public void deltaEnd() { if (!participantsAdded.isEmpty() || !participantsRemoved.isEmpty()) { String rootBlipId = ConversationUtil.getRootBlipId(conversation); WaveletParticipantsChangedEvent event = new WaveletParticipantsChangedEvent(null, null, deltaAuthor.getAddress(), deltaTimestamp, rootBlipId, participantsAdded, participantsRemoved); addEvent(event, capabilities, rootBlipId, messages); } clearOncePerDeltaCollectors(); deltaAuthor = null; deltaTimestamp = null; }
break; case WAVELET_PARTICIPANTS_CHANGED: onWaveletParticipantsChanged(WaveletParticipantsChangedEvent.as(event)); break; case WAVELET_SELF_ADDED:
public void testGenerateWaveletParticipantsChangedEventOnAdd() throws Exception { wavelet.addParticipant(BOB); EventMessageBundle messages = generateAndCheckEvents(EventType.WAVELET_PARTICIPANTS_CHANGED); assertTrue("Only expected one event", messages.getEvents().size() == 1); WaveletParticipantsChangedEvent event = WaveletParticipantsChangedEvent.as(messages.getEvents().get(0)); assertTrue("Bob should be added", event.getParticipantsAdded().contains(BOB.getAddress())); }
public void testGenerateWaveletParticipantsChangedEventOnRemove() throws Exception { wavelet.removeParticipant(ALEX); EventMessageBundle messages = generateAndCheckEvents(EventType.WAVELET_PARTICIPANTS_CHANGED); assertEquals("Expected one event", 1, messages.getEvents().size()); WaveletParticipantsChangedEvent event = WaveletParticipantsChangedEvent.as(messages.getEvents().get(0)); assertTrue( "Alex should be removed", event.getParticipantsRemoved().contains(ALEX.getAddress())); }
participantsAdded.add(targetParticipant.getAddress()); event = new WaveletParticipantsChangedEvent(null, null, participant.getAddress(), System.currentTimeMillis(), rootBlipId, participantsAdded, participantsRemoved); break; new WaveletParticipantsChangedEvent(null, null, participant.getAddress(), System.currentTimeMillis(), rootBlipId, participantsAdded, participantsRemoved); break;
public void refactor_testSerializeAndDeserializeWaveletEvent() throws Exception { List<String> participantsAdded = new ArrayList<String>(); participantsAdded.add("foo@google.com"); participantsAdded.add("bar@google.com"); List<String> participantsRemoved = new ArrayList<String>(); participantsRemoved.add("baz@google.com"); Blip blip = mock(Blip.class); when(blip.getBlipId()).thenReturn("blip123"); Wavelet wavelet = mock(Wavelet.class); when(wavelet.getBlip("blip123")).thenReturn(blip); 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); Context context = new Context(); Event actualEvent = EventSerializer.deserialize(wavelet, bundle, EventSerializer.serialize(expected, context), context); WaveletParticipantsChangedEvent actual = WaveletParticipantsChangedEvent.as(actualEvent); assertEquals(expected, actual); assertEquals(expected.getParticipantsAdded(), actual.getParticipantsAdded()); assertEquals(expected.getParticipantsRemoved(), actual.getParticipantsRemoved()); }