/** * Initializes the robot. Call it if required to re-compute robot's * capabilities. Re-invoke {@link #setupOAuth} if needed. */ protected void initRobot() { capabilityMap = computeCapabilityMap(); version = computeHash(); waveService = new WaveService(version); }
/** * Appends markup ({@code HTML}) content. * * @param markup the markup content to add. */ public void appendMarkup(String markup) { operationQueue.appendMarkupToDocument(this, markup); this.content += convertToPlainText(markup); }
/** * Appends a new blip to the end of the thread of the given blip. * * @param blip the blip whose thread will be appended. * @return an instance of {@link Blip} that represents the new blip. */ public Blip continueThreadOfBlip(Blip blip) { Blip newBlip = newBlip(blip.getWavelet(), "", blip.getParentBlipId(), generateTempBlipId(blip.getWavelet()), blip.getThread().getId()); appendOperation(OperationType.BLIP_CONTINUE_THREAD, blip, Parameter.of(ParamsProperty.BLIP_DATA, newBlip.serialize())); return newBlip; }
public void testBlindWavelet() throws Exception { AbstractRobot robot = new MockRobot(); Wavelet blindWavelet = robot.blindWavelet(WAVE_1, WAVELET_1); assertEquals(0, blindWavelet.getOperationQueue().getPendingOperations().size()); blindWavelet.getParticipants().add("foo@test.com"); blindWavelet.reply("\n"); assertEquals(2, blindWavelet.getOperationQueue().getPendingOperations().size()); assertEquals(OperationType.WAVELET_ADD_PARTICIPANT_NEWSYNTAX.method(), blindWavelet.getOperationQueue().getPendingOperations().get(0).getMethod()); assertEquals(OperationType.WAVELET_APPEND_BLIP.method(), blindWavelet.getOperationQueue().getPendingOperations().get(1).getMethod()); }
public void testTextIteratorWithoutShift() { 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(); assertNotNull(range); assertEquals(i * 2 + 1, range.getStart()); assertEquals(i * 2 + 2, range.getEnd()); } assertFalse(iterator.hasNext()); }
public void testSingleshotIterator() throws Exception { Blip blip = new Blip("blip1", "\n1 1 1", null, null, wavelet); SingleshotIterator iterator = new BlipIterator.SingleshotIterator(blip, 0, 1); assertTrue(iterator.hasNext()); Range range = iterator.next(); assertEquals(0, range.getStart()); assertEquals(1, range.getEnd()); assertFalse(iterator.hasNext()); }
public void testTypeConstructor() { FormElement formElement = new FormElement(ElementType.BUTTON); assertEquals(ElementType.BUTTON, formElement.getType()); // without null check assertEquals(EMPTY_STRING, formElement.getProperty(NAME)); assertEquals(EMPTY_STRING, formElement.getProperty(DEFAULT_VALUE)); assertEquals(EMPTY_STRING, formElement.getProperty(VALUE)); // with null check assertEquals(EMPTY_STRING, formElement.getName()); assertEquals(EMPTY_STRING, formElement.getDefaultValue()); assertEquals(EMPTY_STRING, formElement.getValue()); }
public void testImageConstructor() { Image image = new Image(URL, WIDTH, HEIGHT, CAPTION); assertEquals(ElementType.IMAGE, image.getType()); assertNull(image.getAttachmentId()); assertEquals(CAPTION, image.getCaption()); assertEquals(URL, image.getUrl()); assertEquals(WIDTH, image.getWidth()); assertEquals(HEIGHT, image.getHeight()); }
public void testDeleteAll() { Blip blip = newBlip("\nNew title\nNew content", Arrays.asList( new Annotation("style/fontWeight", "bold", new Range(10,11)), new Annotation("conv/title", "", new Range(0,10)))); blip.all().delete(); assertEquals("\n", blip.getContent()); }
private static void assertEquals(Annotation one, Annotation two) { assertEquals(one.getName(), two.getName()); assertEquals(one.getValue(), two.getValue()); assertEquals(one.getRange().getStart(), two.getRange().getStart()); assertEquals(one.getRange().getEnd(), two.getRange().getEnd()); } }
public void testServiceProfileRequest() throws Exception { AbstractRobot robot = new MockRobot(); MockWriter writer = new MockWriter(); robot.doGet(makeMockRequest(PROFILE_PATH), makeMockResponse(writer)); String profileJson = writer.getString(); String expectedProfileJson = "{\"address\":\"\",\"name\":\"Foo\",\"imageUrl\":\"http://foo.com/foo.png\"," + "\"profileUrl\":\"http://foo.com\"}"; assertEquals(expectedProfileJson, profileJson); }
public void testUrlConstructor() { Gadget gadget = new Gadget(URL); assertEquals(ElementType.GADGET, gadget.getType()); assertEquals(URL, gadget.getProperty(URL)); assertEquals(URL, gadget.getUrl()); } }
public void testAttachmentConstructor() { Image image = new Image(ATTACHMENT_ID, CAPTION); assertEquals(ElementType.IMAGE, image.getType()); assertEquals(ATTACHMENT_ID, image.getAttachmentId()); assertEquals(CAPTION, image.getCaption()); assertNull(image.getUrl()); }
/** * Constructs an instance representing an explicitly set range. * * @param blip the blip to represent. * @param start the start index of the range. * @param end the end index of the range. * @return an instance of blip references. */ public static BlipContentRefs range(Blip blip, int start, int end) { return new BlipContentRefs(blip, new BlipIterator.SingleshotIterator(blip, start, end), Parameter.of(ParamsProperty.RANGE, new Range(start, end))); }
public void testBlindWavelet() throws Exception { AbstractRobot robot = new MockRobot(); Wavelet blindWavelet = robot.blindWavelet(WAVE_1, WAVELET_1); assertEquals(0, blindWavelet.getOperationQueue().getPendingOperations().size()); blindWavelet.getParticipants().add("foo@test.com"); blindWavelet.reply("\n"); assertEquals(2, blindWavelet.getOperationQueue().getPendingOperations().size()); assertEquals(OperationType.WAVELET_ADD_PARTICIPANT_NEWSYNTAX.method(), blindWavelet.getOperationQueue().getPendingOperations().get(0).getMethod()); assertEquals(OperationType.WAVELET_APPEND_BLIP.method(), blindWavelet.getOperationQueue().getPendingOperations().get(1).getMethod()); }
public void testTextIteratorWithoutShift() { 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(); assertNotNull(range); assertEquals(i * 2 + 1, range.getStart()); assertEquals(i * 2 + 2, range.getEnd()); } assertFalse(iterator.hasNext()); }
public void testSingleshotIterator() throws Exception { Blip blip = new Blip("blip1", "\n1 1 1", null, null, wavelet); SingleshotIterator iterator = new BlipIterator.SingleshotIterator(blip, 0, 1); assertTrue(iterator.hasNext()); Range range = iterator.next(); assertEquals(0, range.getStart()); assertEquals(1, range.getEnd()); assertFalse(iterator.hasNext()); }
public void testServiceProfileRequest() throws Exception { AbstractRobot robot = new MockRobot(); MockWriter writer = new MockWriter(); robot.doGet(makeMockRequest(PROFILE_PATH), makeMockResponse(writer)); String profileJson = writer.getString(); String expectedProfileJson = "{\"address\":\"\",\"name\":\"Foo\",\"imageUrl\":\"http://foo.com/foo.png\"," + "\"profileUrl\":\"http://foo.com\"}"; assertEquals(expectedProfileJson, profileJson); }
public void testDefaultConstructor() { Gadget gadget = new Gadget(); assertEquals(ElementType.GADGET, gadget.getType()); assertEquals(EMPTY_STRING, gadget.getProperty(URL)); assertEquals(EMPTY_STRING, gadget.getUrl()); }