/** * Replies to the conversation in this wavelet. * * @param initialContent the initial content of the reply. * @return an instance of {@link Blip} that represents a transient version of * the reply. * * @throws IllegalArgumentException if {@code initialContent} does not start * with a newline character. */ public Blip reply(String initialContent) { if (initialContent == null || !initialContent.startsWith("\n")) { throw new IllegalArgumentException("Initial content should start with a newline character"); } return operationQueue.appendBlipToWavelet(this, initialContent); }
public void testReply() throws Exception { assertEquals(1, wavelet.getBlips().size()); Blip replyBlip1 = mock(Blip.class); when(replyBlip1.getBlipId()).thenReturn("replyblip1"); Blip replyBlip2 = mock(Blip.class); when(replyBlip2.getBlipId()).thenReturn("replyblip2"); when(opQueue.appendBlipToWavelet(wavelet, "\n")).thenReturn(replyBlip1); when(opQueue.appendBlipToWavelet(wavelet, "\nFoo")).thenReturn(replyBlip2); try { wavelet.reply(null); fail("Should have failed when calling Wavelet.reply(null)."); } catch (IllegalArgumentException e) { // Expected. } try { wavelet.reply("Foo"); fail("Should have failed when calling Wavelet.reply(String) with arg that doesn't start " + "with a newline char."); } catch (IllegalArgumentException e) { // Expected. } Blip newBlip1 = wavelet.reply("\n"); Blip newBlip2 = wavelet.reply("\nFoo"); //operation must be submitted before it is added to wavelet, so should still be 1 assertEquals(1, wavelet.getBlips().size()); assertTrue(newBlip1.getBlipId().contains("replyblip1")); assertTrue(newBlip2.getBlipId().contains("replyblip2")); }
public void testReply() throws Exception { assertEquals(1, wavelet.getBlips().size()); Blip replyBlip1 = mock(Blip.class); when(replyBlip1.getBlipId()).thenReturn("replyblip1"); Blip replyBlip2 = mock(Blip.class); when(replyBlip2.getBlipId()).thenReturn("replyblip2"); when(opQueue.appendBlipToWavelet(wavelet, "\n")).thenReturn(replyBlip1); when(opQueue.appendBlipToWavelet(wavelet, "\nFoo")).thenReturn(replyBlip2); try { wavelet.reply(null); fail("Should have failed when calling Wavelet.reply(null)."); } catch (IllegalArgumentException e) { // Expected. } try { wavelet.reply("Foo"); fail("Should have failed when calling Wavelet.reply(String) with arg that doesn't start " + "with a newline char."); } catch (IllegalArgumentException e) { // Expected. } Blip newBlip1 = wavelet.reply("\n"); Blip newBlip2 = wavelet.reply("\nFoo"); //operation must be submitted before it is added to wavelet, so should still be 1 assertEquals(1, wavelet.getBlips().size()); assertTrue(newBlip1.getBlipId().contains("replyblip1")); assertTrue(newBlip2.getBlipId().contains("replyblip2")); }