/** * Returns the new blip. * * @return the new blip. */ public Blip getNewBlip() { return wavelet.getBlip(newBlipId); }
public void testCreateChildOfBlip() throws Exception { Blip blip = mock(Blip.class); when(blip.getBlipId()).thenReturn("blip1"); when(blip.getWavelet()).thenReturn(wavelet); Map<String, Blip> blips = new HashMap<String, Blip>(); blips.put("blip1", blip); when(wavelet.getBlip("blip1")).thenReturn(blip); when(wavelet.getBlips()).thenReturn(blips); OperationQueue queue = new OperationQueue(); Blip newBlip = queue.createChildOfBlip(blip); assertEquals(blip.getBlipId(), newBlip.getParentBlipId()); assertEquals(blip, newBlip.getParentBlip()); assertEquals(2, blips.size()); } }
/** * Returns the removed blip. * * @return the removed blip. */ public Blip getRemovedBlip() { return wavelet.getBlip(removedBlipId); }
public void testCreateChildOfBlip() throws Exception { Blip blip = mock(Blip.class); when(blip.getBlipId()).thenReturn("blip1"); when(blip.getWavelet()).thenReturn(wavelet); Map<String, Blip> blips = new HashMap<String, Blip>(); blips.put("blip1", blip); when(wavelet.getBlip("blip1")).thenReturn(blip); when(wavelet.getBlips()).thenReturn(blips); OperationQueue queue = new OperationQueue(); Blip newBlip = queue.createChildOfBlip(blip); assertEquals(blip.getBlipId(), newBlip.getParentBlipId()); assertEquals(blip, newBlip.getParentBlip()); assertEquals(2, blips.size()); } }
@Override public Blip getBlip() { return wavelet.getBlip(blipId); }
/** * Creates or updates an existing shadow blip that should shadow the given * blip. * * @param blipToShadow the blip that should be shadowed. */ private void createOrUpdateShadowBlip(Blip blipToShadow) { Wavelet wavelet = blipToShadow.getWavelet(); String blipId = blipToShadow.getBlipId(); if (shadowBlipMap.containsKey(blipId)) { Blip shadowBlip = wavelet.getBlip(shadowBlipMap.get(blipId)); updateShadowBlip(shadowBlip, blipToShadow); } else { updateShadowMap(wavelet); if (!shadowBlipMap.containsKey(blipId)) { createShadowBlip(blipToShadow); } else { // Update existing shadow Blip Blip shadowBlip = wavelet.getBlip(shadowBlipMap.get(blipId)); updateShadowBlip(shadowBlip, blipToShadow); } } }
public void refactor_testSerializeAndDeserializeBlipEvent() throws Exception { List<String> contributorsAdded = new ArrayList<String>(); contributorsAdded.add("foo@google.com"); contributorsAdded.add("bar@google.com"); List<String> contributorsRemoved = new ArrayList<String>(); contributorsRemoved.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); 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); Context context = new Context(); Event actualEvent = EventSerializer.deserialize(wavelet, bundle, EventSerializer.serialize(expected, context), context); BlipContributorsChangedEvent actual = BlipContributorsChangedEvent.as(actualEvent); assertEquals(expected, actual); assertEquals(expected.getContributorsAdded(), actual.getContributorsAdded()); assertEquals(expected.getContributorsRemoved(), actual.getContributorsRemoved()); }
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 refactor_testSerializeAndDeserializeBlipEvent() throws Exception { List<String> contributorsAdded = new ArrayList<String>(); contributorsAdded.add("foo@google.com"); contributorsAdded.add("bar@google.com"); List<String> contributorsRemoved = new ArrayList<String>(); contributorsRemoved.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); 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); Context context = new Context(); Event actualEvent = EventSerializer.deserialize(wavelet, bundle, EventSerializer.serialize(expected, context), context); BlipContributorsChangedEvent actual = BlipContributorsChangedEvent.as(actualEvent); assertEquals(expected, actual); assertEquals(expected.getContributorsAdded(), actual.getContributorsAdded()); assertEquals(expected.getContributorsRemoved(), actual.getContributorsRemoved()); }
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 refactor_testSerializeAndDeserializeGadgetStateChanged() throws Exception { Map<String, String> oldState = new HashMap<String, String>(); oldState.put("key1", "value1"); oldState.put("key2", "value2"); 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); Context context = new Context(); Event actualEvent = EventSerializer.deserialize(wavelet, bundle, EventSerializer.serialize(expected, context), context); GadgetStateChangedEvent actual = GadgetStateChangedEvent.as(actualEvent); assertEquals(expected, actual); assertEquals(expected.getIndex(), actual.getIndex()); assertEquals(expected.getOldState(),actual.getOldState()); }
public void refactor_testSerializeAndDeserializeGadgetStateChanged() throws Exception { Map<String, String> oldState = new HashMap<String, String>(); oldState.put("key1", "value1"); oldState.put("key2", "value2"); 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); Context context = new Context(); Event actualEvent = EventSerializer.deserialize(wavelet, bundle, EventSerializer.serialize(expected, context), context); GadgetStateChangedEvent actual = GadgetStateChangedEvent.as(actualEvent); assertEquals(expected, actual); assertEquals(expected.getIndex(), actual.getIndex()); assertEquals(expected.getOldState(),actual.getOldState()); }