public void testDocumentModifyParametersForAnnotate() { Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null); blip.all().replace("foo foo foo"); blip.all("foo").annotate("key", "value1", "value2", "value3"); List<OperationRequest> ops = blip.getOperationQueue().getPendingOperations(); DocumentModifyAction action = (DocumentModifyAction) ops.get(ops.size() - 1).getParameter( ParamsProperty.MODIFY_ACTION); assertEquals("key", action.getAnnotationKey()); assertEquals(Arrays.asList("value1", "value2", "value3"), action.getValues()); }
public void testDocumentModifyParametersForAnnotate() { Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null); blip.all().replace("foo foo foo"); blip.all("foo").annotate("key", "value1", "value2", "value3"); List<OperationRequest> ops = blip.getOperationQueue().getPendingOperations(); DocumentModifyAction action = (DocumentModifyAction) ops.get(ops.size() - 1).getParameter( ParamsProperty.MODIFY_ACTION); assertEquals("key", action.getAnnotationKey()); assertEquals(Arrays.asList("value1", "value2", "value3"), action.getValues()); }
public void testDocumentModifyParametersForInsertInsertAfterAndReplace() throws Exception { Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null); blip.at(0).insert(new Image("http://a/b.gif", 100, 100, "Foo"), Plaintext.of("bold"), Plaintext.of("text")); List<OperationRequest> ops = blip.getOperationQueue().getPendingOperations(); DocumentModifyAction action = (DocumentModifyAction) ops.get(ops.size() - 1).getParameter( ParamsProperty.MODIFY_ACTION); assertEquals(3, action.getValues().size()); assertFalse(action.hasTextAt(0)); assertNull(action.getValues().get(0)); assertTrue(action.hasTextAt(1)); assertEquals("bold", action.getValues().get(1)); assertTrue(action.hasTextAt(2)); assertEquals("text", action.getValues().get(2)); assertEquals(3, action.getElements().size()); Element el = action.getElements().get(0); assertTrue(el instanceof Image); assertEquals("http://a/b.gif", ((Image) el).getUrl()); assertNull(action.getElements().get(1)); assertNull(action.getElements().get(2)); }
public void testDocumentModifyParametersForInsertInsertAfterAndReplace() throws Exception { Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null); blip.at(0).insert(new Image("http://a/b.gif", 100, 100, "Foo"), Plaintext.of("bold"), Plaintext.of("text")); List<OperationRequest> ops = blip.getOperationQueue().getPendingOperations(); DocumentModifyAction action = (DocumentModifyAction) ops.get(ops.size() - 1).getParameter( ParamsProperty.MODIFY_ACTION); assertEquals(3, action.getValues().size()); assertFalse(action.hasTextAt(0)); assertNull(action.getValues().get(0)); assertTrue(action.hasTextAt(1)); assertEquals("bold", action.getValues().get(1)); assertTrue(action.hasTextAt(2)); assertEquals("text", action.getValues().get(2)); assertEquals(3, action.getElements().size()); Element el = action.getElements().get(0); assertTrue(el instanceof Image); assertEquals("http://a/b.gif", ((Image) el).getUrl()); assertNull(action.getElements().get(1)); assertNull(action.getElements().get(2)); }