public void testDocumentModifyParametersForClearAnnotation() { Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null); blip.all().clearAnnotation("key"); List<OperationRequest> ops = blip.getOperationQueue().getPendingOperations(); DocumentModifyAction action = (DocumentModifyAction) ops.get(ops.size() - 1).getParameter( ParamsProperty.MODIFY_ACTION); assertEquals("key", action.getAnnotationKey()); }
public void testDocumentModifyParametersForClearAnnotation() { Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null); blip.all().clearAnnotation("key"); List<OperationRequest> ops = blip.getOperationQueue().getPendingOperations(); DocumentModifyAction action = (DocumentModifyAction) ops.get(ops.size() - 1).getParameter( ParamsProperty.MODIFY_ACTION); assertEquals("key", action.getAnnotationKey()); }
@SuppressWarnings("unchecked") public void testDocumentModifyParametersForUpdateElement() { Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null); Map<String, String> newProperties = new HashMap<String, String>(); newProperties.put("url", "http://www.google.com/gadget.xml"); blip.first(ElementType.GADGET).updateElement(newProperties); List<OperationRequest> ops = blip.getOperationQueue().getPendingOperations(); DocumentModifyAction action = (DocumentModifyAction) ops.get(0).getParameter( ParamsProperty.MODIFY_ACTION); assertEquals("http://www.google.com/gadget.xml", action.getElement(0).getProperty("url")); }
@SuppressWarnings("unchecked") public void testDocumentModifyParametersForUpdateElement() { Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null); Map<String, String> newProperties = new HashMap<String, String>(); newProperties.put("url", "http://www.google.com/gadget.xml"); blip.first(ElementType.GADGET).updateElement(newProperties); List<OperationRequest> ops = blip.getOperationQueue().getPendingOperations(); DocumentModifyAction action = (DocumentModifyAction) ops.get(0).getParameter( ParamsProperty.MODIFY_ACTION); assertEquals("http://www.google.com/gadget.xml", action.getElement(0).getProperty("url")); }
OperationRequest op = blip.getOperationQueue().modifyDocument(blip);
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 testProxyFor() throws Exception { Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null); Blip proxiedBlip = blip.proxyFor("proxyuser"); assertEquals(blip.getBlipId(), proxiedBlip.getBlipId()); assertEquals(blip.getWaveId(), proxiedBlip.getWaveId()); assertEquals(blip.getWaveletId(), proxiedBlip.getWaveletId()); proxiedBlip.reply(); List<OperationRequest> pendingOps = proxiedBlip.getOperationQueue().getPendingOperations(); assertEquals(1, pendingOps.size()); assertEquals("proxyuser", pendingOps.get(0).getParameter(ParamsProperty.PROXYING_FOR)); }
public void testProxyFor() throws Exception { Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null); Blip proxiedBlip = blip.proxyFor("proxyuser"); assertEquals(blip.getBlipId(), proxiedBlip.getBlipId()); assertEquals(blip.getWaveId(), proxiedBlip.getWaveId()); assertEquals(blip.getWaveletId(), proxiedBlip.getWaveletId()); proxiedBlip.reply(); List<OperationRequest> pendingOps = proxiedBlip.getOperationQueue().getPendingOperations(); assertEquals(1, pendingOps.size()); assertEquals("proxyuser", pendingOps.get(0).getParameter(ParamsProperty.PROXYING_FOR)); }
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)); }