@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")); }
public void testUpdateElement() throws Exception { Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null); String url = "http://www.test.com/image.png"; blip.append(new Image(url, 100, 100, "Cool pix.")); assertEquals(2, blip.getElements().size()); // Update the image by appending a query param to the URL. blip.first(ElementType.IMAGE).updateElement(new MapFunction() { @Override public Map<String, String> call(BlipContent source) { Image matchedImage = (Image) source; Map<String, String> properties = new HashMap<String, String>(); properties.put("url", matchedImage.getUrl() + "?version=newversion"); return properties; } }); Image image = (Image) blip.first(ElementType.IMAGE).value(); assertEquals(url + "?version=newversion", image.getUrl()); }
public void testUpdateElement() throws Exception { Blip blip = newBlip(ROOT_BLIP_ID, Arrays.asList(CHILD_BLIP_ID), null); String url = "http://www.test.com/image.png"; blip.append(new Image(url, 100, 100, "Cool pix.")); assertEquals(2, blip.getElements().size()); // Update the image by appending a query param to the URL. blip.first(ElementType.IMAGE).updateElement(new MapFunction() { @Override public Map<String, String> call(BlipContent source) { Image matchedImage = (Image) source; Map<String, String> properties = new HashMap<String, String>(); properties.put("url", matchedImage.getUrl() + "?version=newversion"); return properties; } }); Image image = (Image) blip.first(ElementType.IMAGE).value(); assertEquals(url + "?version=newversion", image.getUrl()); }