### Question:
FlickrTrendyPhotosActionHandler implements BentenActionHandler { @Override public BentenHandlerResponse handle(BentenMessage bentenMessage) { BentenHandlerResponse bentenHandlerResponse = new BentenHandlerResponse(); try { PhotoList<Photo> response = bentenFlickrClient.getTrendyPhotos(); bentenHandlerResponse.setBentenSlackResponse(SlackFlickrMessageRenderer.renderList(response)); } catch(Exception e) { BentenSlackResponse bentenSlackResponse = new BentenSlackResponse(); bentenSlackResponse.setSlackText("Unable to retrieve trendy photos."); bentenHandlerResponse.setBentenSlackResponse(bentenSlackResponse); } return bentenHandlerResponse; }  @Override BentenHandlerResponse handle(BentenMessage bentenMessage);  }### Answer:
@Test public void testEmptyRequest() { Mockito.when(bentenFlickrClient.getTrendyPhotos()).thenReturn(new PhotoList<>()); BentenHandlerResponse response = flickrTrendyPhotosActionHandler.handle(new BentenMessage()); Assert.hasText(response.getBentenSlackResponse().getSlackText(), "Should have slack message"); }
@Test public void testPopulatedRequest() { PhotoList<Photo> mockResults = new PhotoList<>(); for (int i = 0; i < 3; i++) { mockResults.add(new Photo()); } Mockito.when(bentenFlickrClient.getTrendyPhotos()).thenReturn(mockResults); BentenHandlerResponse response = flickrTrendyPhotosActionHandler.handle(new BentenMessage()); Assert.isTrue(response.getBentenSlackResponse().getBentenSlackAttachments().size() == 3, "Should have 3 attachments"); }
@Test public void testErrorRequest() { Mockito.when(bentenFlickrClient.getBrandCameras("Apple")).thenThrow(new BentenFlickrException("error")); BentenHandlerResponse response = flickrTrendyPhotosActionHandler.handle(new BentenMessage()); Assert.hasText(response.getBentenSlackResponse().getSlackText(), "Should have slack message"); }