### Question:
FlickrSearchPhotosActionHandler implements BentenActionHandler { @Override public BentenHandlerResponse handle(BentenMessage bentenMessage) { String mediaType = BentenMessageHelper.getParameterAsString(bentenMessage,FlickrActionParamaters.PARAMETER_MEDIA_TYPE); String searchValue = BentenMessageHelper.getParameterAsString(bentenMessage,FlickrActionParamaters.PARAMETER_SEARCH_VALUE); Integer searchLimit = BentenMessageHelper.getParameterAsInteger(bentenMessage,FlickrActionParamaters.PARAMETER_SEARCH_LIMIT); BentenHandlerResponse bentenHandlerResponse = new BentenHandlerResponse(); try { PhotoList<Photo> response = bentenFlickrClient.searchPhotos(mediaType, searchValue, searchLimit); bentenHandlerResponse.setBentenSlackResponse(SlackFlickrMessageRenderer.renderList(response)); } catch (Exception e) { BentenSlackResponse bentenSlackResponse = new BentenSlackResponse(); bentenSlackResponse.setSlackText("Unable to search for photos"); bentenHandlerResponse.setBentenSlackResponse(bentenSlackResponse); } return bentenHandlerResponse; }  @Override BentenHandlerResponse handle(BentenMessage bentenMessage);  }### Answer:
@Test public void testEmptyRequest() { Mockito.when(bentenFlickrClient.searchPhotos("all", "cats", 0)).thenReturn(new PhotoList<>()); BentenMessage params = FlickrMessageBuilder.constructSearchPhotosMessage("all", "cats", "0"); BentenHandlerResponse response = flickrSearchPhotosActionHandler.handle(params); 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.searchPhotos("all", "cats", 3)).thenReturn(mockResults); BentenMessage params = FlickrMessageBuilder.constructSearchPhotosMessage("all", "cats", "3"); BentenHandlerResponse response = flickrSearchPhotosActionHandler.handle(params); Assert.isTrue(response.getBentenSlackResponse().getBentenSlackAttachments().size() == 3, "Should have 3 attachments"); }
@Test public void testErrorRequest() { Mockito.when(bentenFlickrClient .searchPhotos("all", "cats", 3)) .thenThrow(new BentenFlickrException("error")); BentenMessage params = FlickrMessageBuilder.constructSearchPhotosMessage("all", "cats", "3"); BentenHandlerResponse response = flickrSearchPhotosActionHandler.handle(params); Assert.hasText(response.getBentenSlackResponse().getSlackText(), "Should have slack message"); }