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_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_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()); }
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_testSerializeAndDeserializeOperationErrorEvent() throws Exception { Wavelet wavelet = mock(Wavelet.class); EventMessageBundle bundle = new EventMessageBundle("http://10.1.1.1", "http://wave-active-api.example.com"); OperationErrorEvent expected = new OperationErrorEvent(wavelet, bundle, "foo@google.com", 123l, "op1", "Error!"); Context context = new Context(); Event actual = EventSerializer.deserialize(wavelet, bundle, EventSerializer.serialize(expected, context), context); assertEquals(expected, actual); }
public void refactor_testSerializeAndDeserializeOperationErrorEvent() throws Exception { Wavelet wavelet = mock(Wavelet.class); EventMessageBundle bundle = new EventMessageBundle("http://10.1.1.1", "http://wave-active-api.example.com"); OperationErrorEvent expected = new OperationErrorEvent(wavelet, bundle, "foo@google.com", 123l, "op1", "Error!"); Context context = new Context(); Event actual = EventSerializer.deserialize(wavelet, bundle, EventSerializer.serialize(expected, context), context); assertEquals(expected, actual); }