@Test public void getBaseObjectWithImageUrlsAndThumbnail() throws URISyntaxException { final String link1Href = "google"; final String link2Href = "yahoo"; final MediaModuleImpl media = context.mock(MediaModuleImpl.class); final Metadata metadata = context.mock(Metadata.class); final Thumbnail thumbnail = context.mock(Thumbnail.class); final Thumbnail[] thumbArr = { thumbnail }; final URI uri = new URI("http: myContents = new LinkedList<SyndContentImpl>(); myContents.add(content); final SyndContent description = context.mock(SyndContent.class); final SyndEntryImpl entry = context.mock(SyndEntryImpl.class); final SyndLinkImpl link1 = context.mock(SyndLinkImpl.class, "link1"); final SyndLinkImpl link2 = context.mock(SyndLinkImpl.class, "link2"); final List<SyndLinkImpl> myLinks = new LinkedList<SyndLinkImpl>(); myLinks.add(link1); myLinks.add(link2); context.checking(new Expectations() { { oneOf(entry).getModule(MediaModule.URI); will(returnValue(media)); oneOf(entry).getTitle(); will(returnValue(title)); oneOf(entry).getLinks(); will(returnValue(myLinks)); oneOf(entry).getDescription(); will(returnValue(description)); allowing(link1).getRel(); will(returnValue("enclosure")); oneOf(link1).getHref(); will(returnValue(link1Href)); allowing(link2).getRel(); will(returnValue("alternate")); oneOf(link2).getHref(); will(returnValue(link2Href)); allowing(media).getMetadata(); will(returnValue(metadata)); allowing(metadata).getThumbnail(); will(returnValue(thumbArr)); oneOf(thumbnail).getUrl(); will(returnValue(uri)); oneOf(entry).getDescription(); will(returnValue(description)); oneOf(description).getValue(); will(returnValue("anything")); oneOf(entry).getContents(); will(returnValue(myContents)); oneOf(content).getValue(); will(returnValue("<p>><img src=\"" + FLICKR_URL + "\" width=\"240\" height=\"144\" /></a></p></")); } }); Activity activity = new Activity(); sut.build(feed, entry, activity); assertEquals(BaseObjectType.PHOTO, activity.getBaseObjectType()); HashMap<String, String> result = activity.getBaseObject(); assertEquals(title, result.get("title")); assertEquals(link1Href, result.get("largerImage")); assertEquals(link2Href, result.get("imagePageURL")); assertEquals(FLICKR_URL, result.get("thumbnail")); assertEquals("", result.get("description")); }
@Override public HashMap<String, String> getBaseObject(final SyndEntry entry) { HashMap<String, String> object = super.getBaseObject(entry); String content = ((SyndContentImpl) entry.getContents().get(0)).getValue(); object.put("thumbnail", content.split("<img src=\"")[1].split("\"")[0]); object.put("description", ""); return object; }
FlickrMapper extends StandardFeedPhotoMapper { @Override public HashMap<String, String> getBaseObject(final SyndEntry entry) { HashMap<String, String> object = super.getBaseObject(entry); String content = ((SyndContentImpl) entry.getContents().get(0)).getValue(); object.put("thumbnail", content.split("<img src=\"")[1].split("\"")[0]); object.put("description", ""); return object; } }
FlickrMapper extends StandardFeedPhotoMapper { @Override public HashMap<String, String> getBaseObject(final SyndEntry entry) { HashMap<String, String> object = super.getBaseObject(entry); String content = ((SyndContentImpl) entry.getContents().get(0)).getValue(); object.put("thumbnail", content.split("<img src=\"")[1].split("\"")[0]); object.put("description", ""); return object; }  }
FlickrMapper extends StandardFeedPhotoMapper { @Override public HashMap<String, String> getBaseObject(final SyndEntry entry) { HashMap<String, String> object = super.getBaseObject(entry); String content = ((SyndContentImpl) entry.getContents().get(0)).getValue(); object.put("thumbnail", content.split("<img src=\"")[1].split("\"")[0]); object.put("description", ""); return object; }  @Override HashMap<String, String> getBaseObject(final SyndEntry entry); }
FlickrMapper extends StandardFeedPhotoMapper { @Override public HashMap<String, String> getBaseObject(final SyndEntry entry) { HashMap<String, String> object = super.getBaseObject(entry); String content = ((SyndContentImpl) entry.getContents().get(0)).getValue(); object.put("thumbnail", content.split("<img src=\"")[1].split("\"")[0]); object.put("description", ""); return object; }  @Override HashMap<String, String> getBaseObject(final SyndEntry entry);  }