@Override public BlipThread createInstance(Type type) { return new BlipThread(null, -1, null, null); } }
/** * @see #blindWavelet(WaveId, WaveletId, String, Map) * * @param threads a collection of threads that belong to this wavelet. */ public Wavelet blindWavelet(WaveId waveId, WaveletId waveletId, String proxyForId, Map<String, Blip> blips, Map<String, BlipThread> threads) { Util.checkIsValidProxyForId(proxyForId); Map<String, String> roles = new HashMap<String, String>(); return new Wavelet(waveId, waveletId, null, new BlipThread("", -1, new ArrayList<String>(), blips), Collections.<String>emptySet(), roles, blips, threads, new OperationQueue(proxyForId)); }
@Override public WaveletData toWaveletData(Wavelet wavelet, Conversation conversation, EventMessageBundle eventMessageBundle) { WaveletData waveletData = super.toWaveletData(wavelet, conversation, eventMessageBundle); List<String> blipIds = Lists.newLinkedList(); for (ConversationBlip conversationBlip : conversation.getRootThread().getBlips()) { blipIds.add(conversationBlip.getId()); } waveletData.setRootThread(new BlipThread("", -1 , blipIds, null)); return waveletData; }
BlipThread rootThread = new BlipThread("", -1, blipIds, blips);
@Override protected void setUp() throws Exception { wavelet = mock(Wavelet.class); when(wavelet.getWaveId()).thenReturn(WaveId.of("example.com", "wave1")); when(wavelet.getWaveletId()).thenReturn(WaveletId.of("example.com", "wavelet1")); when(wavelet.getThread(anyString())).thenReturn(new BlipThread("rootThread", -1, Lists.<String>newArrayList(), new HashMap<String, Blip>())); }
BlipThread thread = entry.getValue(); threads.put(entry.getKey(), new BlipThread(thread.getId(), thread.getLocation(), thread.getBlipIds(), blips));
for (Entry<String, BlipThread> entry : tempThreads.entrySet()) { BlipThread thread = entry.getValue(); threads.put(entry.getKey(), new BlipThread(thread.getId(), thread.getLocation(), thread.getBlipIds(), blips));
@Override protected void setUp() throws Exception { wavelet = mock(Wavelet.class); when(wavelet.getWaveId()).thenReturn(WaveId.of("example.com", "wave1")); when(wavelet.getWaveletId()).thenReturn(WaveletId.of("example.com", "wavelet1")); when(wavelet.getThread(anyString())).thenReturn(new BlipThread("rootThread", -1, Lists.<String>newArrayList(), new HashMap<String, Blip>())); }
@Override protected void setUp() throws Exception { wavelet = mock(Wavelet.class); when(wavelet.getBlips()).thenReturn(blips); when(wavelet.getOperationQueue()).thenReturn(new OperationQueue()); when(wavelet.getWaveId()).thenReturn(WaveId.of("example.com", "wave1")); when(wavelet.getWaveletId()).thenReturn(WaveletId.of("example.com", "wavelet1")); when(wavelet.getThread(anyString())).thenReturn(new BlipThread("rootThread", -1, Lists.newArrayList(ROOT_BLIP_ID, CHILD_BLIP_ID), blips)); }
@Override protected void setUp() throws Exception { wavelet = mock(Wavelet.class); when(wavelet.getBlips()).thenReturn(blips); when(wavelet.getOperationQueue()).thenReturn(new OperationQueue()); when(wavelet.getWaveId()).thenReturn(WaveId.of("example.com", "wave1")); when(wavelet.getWaveletId()).thenReturn(WaveletId.of("example.com", "wavelet1")); when(wavelet.getThread(anyString())).thenReturn(new BlipThread("rootThread", -1, Lists.newArrayList(ROOT_BLIP_ID, CHILD_BLIP_ID), blips)); }
BlipThread rootThread = new BlipThread("", -1, blipIds, blips);
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()); }
/** * Creates a child blip of another blip. * * @param blip the parent blip. * @return an instance of {@link Blip} that represents the new child blip. */ public Blip createChildOfBlip(Blip blip) { // Create a new thread. String tempBlipId = generateTempBlipId(blip.getWavelet()); Wavelet wavelet = blip.getWavelet(); BlipThread thread = new BlipThread(tempBlipId, -1, new ArrayList<String>(), wavelet.getBlips()); // Add the new thread to the blip and wavelet. blip.addThread(thread); wavelet.addThread(thread); // Create a new blip in the new thread. Blip newBlip = newBlip(blip.getWavelet(), "", blip.getBlipId(), tempBlipId, thread.getId()); appendOperation(OperationType.BLIP_CREATE_CHILD, blip, Parameter.of(ParamsProperty.BLIP_DATA, newBlip.serialize())); return newBlip; }
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()); }
new ArrayList<String>() : new ArrayList<String>(originalRootThread.getBlipIds()); BlipThread rootThread = new BlipThread("", -1, rootThreadBlipIds, blips);
/** * Inserts a new inline blip at a specified location. * * @param blip the blip to anchor this inline blip from. * @param position the position in the given blip to insert this new inline * blip. * @return an instance of {@link Blip} that represents the inline blip. */ public Blip insertInlineBlipToDocument(Blip blip, int position) { // Create a new thread. String tempBlipId = generateTempBlipId(blip.getWavelet()); Wavelet wavelet = blip.getWavelet(); BlipThread thread = new BlipThread(tempBlipId, position, new ArrayList<String>(), wavelet.getBlips()); // Add the new thread to the blip and wavelet. blip.addThread(thread); wavelet.addThread(thread); // Create a new blip in the new thread. Blip inlineBlip = newBlip(blip.getWavelet(), "", blip.getBlipId(), tempBlipId, thread.getId()); appendOperation(OperationType.DOCUMENT_INSERT_INLINE_BLIP, blip, Parameter.of(ParamsProperty.INDEX, position), Parameter.of(ParamsProperty.BLIP_DATA, inlineBlip.serialize())); return inlineBlip; }
blipIds.add(blip.getId()); eventMessageBundle.addThread(threadId, new BlipThread(thread.getId(), location, blipIds, null));