/** * 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 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 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 testSubmitWith() throws Exception { OperationQueue queue = new OperationQueue(); queue.createWavelet("example.com", Collections.<String>emptySet()); OperationQueue queue2 = new OperationQueue(); queue2.setTitleOfWavelet(wavelet, "My title"); queue2.submitWith(queue); List<OperationRequest> ops = queue.getPendingOperations(); assertEquals(2, ops.size()); assertEquals(OperationType.ROBOT_CREATE_WAVELET.method(), ops.get(0).getMethod()); assertEquals(OperationType.WAVELET_SET_TITLE.method(), ops.get(1).getMethod()); assertEquals(queue.getPendingOperations(), queue2.getPendingOperations()); }
public void testSubmitWith() throws Exception { OperationQueue queue = new OperationQueue(); queue.createWavelet("example.com", Collections.<String>emptySet()); OperationQueue queue2 = new OperationQueue(); queue2.setTitleOfWavelet(wavelet, "My title"); queue2.submitWith(queue); List<OperationRequest> ops = queue.getPendingOperations(); assertEquals(2, ops.size()); assertEquals(OperationType.ROBOT_CREATE_WAVELET.method(), ops.get(0).getMethod()); assertEquals(OperationType.WAVELET_SET_TITLE.method(), ops.get(1).getMethod()); assertEquals(queue.getPendingOperations(), queue2.getPendingOperations()); }
public void testProxyFor() throws Exception { OperationQueue queue = new OperationQueue(); queue.createWavelet("google.com", Collections.<String>emptySet()); OperationQueue proxyingForQueue = queue.proxyFor("foo"); assertEquals(1, proxyingForQueue.getPendingOperations().size()); proxyingForQueue.setTitleOfWavelet(wavelet, "My title"); List<OperationRequest> ops = proxyingForQueue.getPendingOperations(); assertEquals(2, ops.size()); assertEquals(OperationType.ROBOT_CREATE_WAVELET.method(), ops.get(0).getMethod()); assertNull(ops.get(0).getParameter(ParamsProperty.PROXYING_FOR)); assertEquals(OperationType.WAVELET_SET_TITLE.method(), ops.get(1).getMethod()); assertEquals("foo", ops.get(1).getParameter(ParamsProperty.PROXYING_FOR)); OperationQueue nonProxyingForQueue = proxyingForQueue.proxyFor(null); nonProxyingForQueue.fetchWavelet(WaveId.of("example.com", "wave2"), WaveletId.of("example.com", "wavelet2")); ops = nonProxyingForQueue.getPendingOperations(); assertEquals(3, ops.size()); assertNull(ops.get(2).getParameter(ParamsProperty.PROXYING_FOR)); }
public void testProxyFor() throws Exception { OperationQueue queue = new OperationQueue(); queue.createWavelet("google.com", Collections.<String>emptySet()); OperationQueue proxyingForQueue = queue.proxyFor("foo"); assertEquals(1, proxyingForQueue.getPendingOperations().size()); proxyingForQueue.setTitleOfWavelet(wavelet, "My title"); List<OperationRequest> ops = proxyingForQueue.getPendingOperations(); assertEquals(2, ops.size()); assertEquals(OperationType.ROBOT_CREATE_WAVELET.method(), ops.get(0).getMethod()); assertNull(ops.get(0).getParameter(ParamsProperty.PROXYING_FOR)); assertEquals(OperationType.WAVELET_SET_TITLE.method(), ops.get(1).getMethod()); assertEquals("foo", ops.get(1).getParameter(ParamsProperty.PROXYING_FOR)); OperationQueue nonProxyingForQueue = proxyingForQueue.proxyFor(null); nonProxyingForQueue.fetchWavelet(WaveId.of("example.com", "wave2"), WaveletId.of("example.com", "wavelet2")); ops = nonProxyingForQueue.getPendingOperations(); assertEquals(3, ops.size()); assertNull(ops.get(2).getParameter(ParamsProperty.PROXYING_FOR)); }