@Test public void testRenderListForNoCameras() { List<Camera> mockResults = new ArrayList<>(); BentenSlackResponse response = SlackFlickrMessageRenderer.renderList(mockResults); Assert.hasText(response.getSlackText(), "Should have slack message"); Assert.isTrue(response.getBentenSlackAttachments().size() == 0, "Should have no attachments"); }
public static BentenSlackResponse renderList(PhotoList<Photo> photos) { BentenSlackResponse bentenSlackResponse = new BentenSlackResponse(); SlackFormatter slackFormatter = SlackFormatter.create(); List<BentenSlackAttachment> attachments = new ArrayList<>(); if (photos.size() > 0) { slackFormatter.text(String.format("Results found (%d):\n", photos.size())); for (Photo photo : photos) { BentenSlackAttachment attachment = new BentenSlackAttachment(); attachment.setTitle(photo.getTitle()); attachment.setTitle_link(photo.getUrl()); attachment.setThumb_url(photo.getSmallUrl()); attachments.add(attachment); } } else { slackFormatter.text("No photos found."); } bentenSlackResponse.setSlackText(slackFormatter.build()); bentenSlackResponse.setBentenSlackAttachments(attachments); return bentenSlackResponse; }
SlackFlickrMessageRenderer { public static BentenSlackResponse renderList(PhotoList<Photo> photos) { BentenSlackResponse bentenSlackResponse = new BentenSlackResponse(); SlackFormatter slackFormatter = SlackFormatter.create(); List<BentenSlackAttachment> attachments = new ArrayList<>(); if (photos.size() > 0) { slackFormatter.text(String.format("Results found (%d):\n", photos.size())); for (Photo photo : photos) { BentenSlackAttachment attachment = new BentenSlackAttachment(); attachment.setTitle(photo.getTitle()); attachment.setTitle_link(photo.getUrl()); attachment.setThumb_url(photo.getSmallUrl()); attachments.add(attachment); } } else { slackFormatter.text("No photos found."); } bentenSlackResponse.setSlackText(slackFormatter.build()); bentenSlackResponse.setBentenSlackAttachments(attachments); return bentenSlackResponse; } }
SlackFlickrMessageRenderer { public static BentenSlackResponse renderList(PhotoList<Photo> photos) { BentenSlackResponse bentenSlackResponse = new BentenSlackResponse(); SlackFormatter slackFormatter = SlackFormatter.create(); List<BentenSlackAttachment> attachments = new ArrayList<>(); if (photos.size() > 0) { slackFormatter.text(String.format("Results found (%d):\n", photos.size())); for (Photo photo : photos) { BentenSlackAttachment attachment = new BentenSlackAttachment(); attachment.setTitle(photo.getTitle()); attachment.setTitle_link(photo.getUrl()); attachment.setThumb_url(photo.getSmallUrl()); attachments.add(attachment); } } else { slackFormatter.text("No photos found."); } bentenSlackResponse.setSlackText(slackFormatter.build()); bentenSlackResponse.setBentenSlackAttachments(attachments); return bentenSlackResponse; }  }
SlackFlickrMessageRenderer { public static BentenSlackResponse renderList(PhotoList<Photo> photos) { BentenSlackResponse bentenSlackResponse = new BentenSlackResponse(); SlackFormatter slackFormatter = SlackFormatter.create(); List<BentenSlackAttachment> attachments = new ArrayList<>(); if (photos.size() > 0) { slackFormatter.text(String.format("Results found (%d):\n", photos.size())); for (Photo photo : photos) { BentenSlackAttachment attachment = new BentenSlackAttachment(); attachment.setTitle(photo.getTitle()); attachment.setTitle_link(photo.getUrl()); attachment.setThumb_url(photo.getSmallUrl()); attachments.add(attachment); } } else { slackFormatter.text("No photos found."); } bentenSlackResponse.setSlackText(slackFormatter.build()); bentenSlackResponse.setBentenSlackAttachments(attachments); return bentenSlackResponse; }  static BentenSlackResponse renderList(PhotoList<Photo> photos); static BentenSlackResponse renderList(List<Camera> cameras); }
SlackFlickrMessageRenderer { public static BentenSlackResponse renderList(PhotoList<Photo> photos) { BentenSlackResponse bentenSlackResponse = new BentenSlackResponse(); SlackFormatter slackFormatter = SlackFormatter.create(); List<BentenSlackAttachment> attachments = new ArrayList<>(); if (photos.size() > 0) { slackFormatter.text(String.format("Results found (%d):\n", photos.size())); for (Photo photo : photos) { BentenSlackAttachment attachment = new BentenSlackAttachment(); attachment.setTitle(photo.getTitle()); attachment.setTitle_link(photo.getUrl()); attachment.setThumb_url(photo.getSmallUrl()); attachments.add(attachment); } } else { slackFormatter.text("No photos found."); } bentenSlackResponse.setSlackText(slackFormatter.build()); bentenSlackResponse.setBentenSlackAttachments(attachments); return bentenSlackResponse; }  static BentenSlackResponse renderList(PhotoList<Photo> photos); static BentenSlackResponse renderList(List<Camera> cameras);  }