/** * Sets the wavelet title. * * @param title the new title to be set. */ public void setTitle(String title) { if (title.contains("\n")) { throw new IllegalArgumentException("Wavelet title should not contain a newline character. " + "Specified: " + title); } operationQueue.setTitleOfWavelet(this, title); this.title = title; // Adjust the content of the root blip, if it is available in the context. Blip rootBlip = getRootBlip(); if (rootBlip != null) { String content = "\n"; int indexOfSecondNewline = rootBlip.getContent().indexOf('\n', 1); if (indexOfSecondNewline != -1) { content = rootBlip.getContent().substring(indexOfSecondNewline); } rootBlip.setContent("\n" + title + content); } }
public void testSetTitleAdjustEmptyRootBlipProperly() throws Exception { when(rootBlip.getContent()).thenReturn("\n"); wavelet.setTitle("New title"); verify(opQueue).setTitleOfWavelet(wavelet, "New title"); verify(rootBlip).setContent("\nNew title\n"); }
public void testSetTitleAdjustEmptyRootBlipProperly() throws Exception { when(rootBlip.getContent()).thenReturn("\n"); wavelet.setTitle("New title"); verify(opQueue).setTitleOfWavelet(wavelet, "New title"); verify(rootBlip).setContent("\nNew title\n"); }
public void testSetTitle() throws Exception { when(rootBlip.getContent()).thenReturn("\nOld title\n\nContent"); wavelet.setTitle("New title"); verify(opQueue).setTitleOfWavelet(wavelet, "New title"); verify(rootBlip).setContent("\nNew title\n\nContent"); }
public void testSetTitleAdjustRootBlipWithOneLineProperly() throws Exception { when(rootBlip.getContent()).thenReturn("\nOld title"); wavelet.setTitle("New title"); verify(opQueue).setTitleOfWavelet(wavelet, "New title"); verify(rootBlip).setContent("\nNew title\n"); }
public void testSetTitle() throws Exception { when(rootBlip.getContent()).thenReturn("\nOld title\n\nContent"); wavelet.setTitle("New title"); verify(opQueue).setTitleOfWavelet(wavelet, "New title"); verify(rootBlip).setContent("\nNew title\n\nContent"); }
public void testSetTitleAdjustRootBlipWithOneLineProperly() throws Exception { when(rootBlip.getContent()).thenReturn("\nOld title"); wavelet.setTitle("New title"); verify(opQueue).setTitleOfWavelet(wavelet, "New title"); verify(rootBlip).setContent("\nNew title\n"); }
blip.shift(end, start - end); iterator.shift(-1); blip.setContent(blip.getContent().substring(0, start) + blip.getContent().substring(end)); break; blip.setContent(blip.getContent().substring(0, start) + text + blip.getContent().substring(end));
public void testTextIteratorDeletingMatches() { Blip blip = new Blip("blip1", "\n1 1 1", null, null, wavelet); TextIterator iterator = new BlipIterator.TextIterator(blip, "1", -1); for (int i = 0; i < 3; ++i) { assertTrue(iterator.hasNext()); Range range = iterator.next(); assertEquals(i + 1, range.getStart()); blip.setContent(blip.getContent().substring(0, range.getStart()) + blip.getContent().substring(range.getEnd())); iterator.shift(-1); } assertFalse(iterator.hasNext()); assertEquals("\n ", blip.getContent()); }
public void testTextIteratorDeletingMatches() { Blip blip = new Blip("blip1", "\n1 1 1", null, null, wavelet); TextIterator iterator = new BlipIterator.TextIterator(blip, "1", -1); for (int i = 0; i < 3; ++i) { assertTrue(iterator.hasNext()); Range range = iterator.next(); assertEquals(i + 1, range.getStart()); blip.setContent(blip.getContent().substring(0, range.getStart()) + blip.getContent().substring(range.getEnd())); iterator.shift(-1); } assertFalse(iterator.hasNext()); assertEquals("\n ", blip.getContent()); }
public void testTextIteratorShiftInsertAfter() { Blip blip = new Blip("blip1", "\nfoofoofoo", null, null, wavelet); TextIterator iterator = new BlipIterator.TextIterator(blip, "foo", -1); for (int i = 0; i < 3; ++i) { assertTrue(iterator.hasNext()); Range range = iterator.next(); assertEquals(i * 6 + 1, range.getStart()); blip.setContent(blip.getContent().substring(0, range.getEnd()) + "foo" + blip.getContent().substring(range.getEnd())); iterator.shift(range.getEnd() - range.getStart() + 2); } assertFalse(iterator.hasNext()); assertEquals("\nfoofoofoofoofoofoo", blip.getContent()); }
public void testTextIteratorShiftInsertAfter() { Blip blip = new Blip("blip1", "\nfoofoofoo", null, null, wavelet); TextIterator iterator = new BlipIterator.TextIterator(blip, "foo", -1); for (int i = 0; i < 3; ++i) { assertTrue(iterator.hasNext()); Range range = iterator.next(); assertEquals(i * 6 + 1, range.getStart()); blip.setContent(blip.getContent().substring(0, range.getEnd()) + "foo" + blip.getContent().substring(range.getEnd())); iterator.shift(range.getEnd() - range.getStart() + 2); } assertFalse(iterator.hasNext()); assertEquals("\nfoofoofoofoofoofoo", blip.getContent()); }