@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; } });
@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; } });
@Override public BlipContent call(BlipContent source) { Image matchedImage = (Image) source; return Plaintext.of(matchedImage.getUrl()); } });
@Override public BlipContent call(BlipContent source) { Image matchedImage = (Image) source; return Plaintext.of(matchedImage.getUrl()); } });
@Override public BlipContent call(BlipContent source) { Image matchedImage = (Image) source; return new Image(matchedImage.getUrl() + "?query=foo", matchedImage.getWidth(), matchedImage.getHeight(), matchedImage.getCaption()); } });
@Override public BlipContent call(BlipContent source) { Image matchedImage = (Image) source; return new Image(matchedImage.getUrl() + "?query=foo", matchedImage.getWidth(), matchedImage.getHeight(), matchedImage.getCaption()); } });
public void testImgSerialization() { convertBackAndForth("<img src=\"http://www.example.com/image.png\"></img>"); convertBackAndForth( "<img src=\"http://www.example.com/image.png\" width=\"100\" height=\"20\"></img>"); Element element = createApiElementFromXml("<img src=\"http://www.example.com/image.png\"></img>"); assertTrue(element instanceof Image); assertEquals("http://www.example.com/image.png", ((Image) element).getUrl()); }
public void testImgSerialization() { convertBackAndForth("<img src=\"http://www.example.com/image.png\"></img>"); convertBackAndForth( "<img src=\"http://www.example.com/image.png\" width=\"100\" height=\"20\"></img>"); Element element = createApiElementFromXml("<img src=\"http://www.example.com/image.png\"></img>"); assertTrue(element instanceof Image); assertEquals("http://www.example.com/image.png", ((Image) element).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()); }
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 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)); }
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()); }
public void testDefaultConstructor() { Image image = new Image(); assertEquals(ElementType.IMAGE, image.getType()); assertNull(image.getAttachmentId()); assertNull(image.getCaption()); assertNull(image.getUrl()); }
public void testDefaultConstructor() { Image image = new Image(); assertEquals(ElementType.IMAGE, image.getType()); assertNull(image.getAttachmentId()); assertNull(image.getCaption()); assertNull(image.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()); }
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 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 testGettersAndSetters() { Image image = new Image(); image.setAttachmentId(ATTACHMENT_ID); image.setCaption(CAPTION); image.setUrl(URL); image.setWidth(WIDTH); image.setHeight(HEIGHT); assertEquals(ATTACHMENT_ID, image.getAttachmentId()); assertEquals(CAPTION, image.getCaption()); assertEquals(URL, image.getUrl()); assertEquals(WIDTH, image.getWidth()); assertEquals(HEIGHT, image.getHeight()); }
public void testGettersAndSetters() { Image image = new Image(); image.setAttachmentId(ATTACHMENT_ID); image.setCaption(CAPTION); image.setUrl(URL); image.setWidth(WIDTH); image.setHeight(HEIGHT); assertEquals(ATTACHMENT_ID, image.getAttachmentId()); assertEquals(CAPTION, image.getCaption()); assertEquals(URL, image.getUrl()); assertEquals(WIDTH, image.getWidth()); assertEquals(HEIGHT, image.getHeight()); }