### Question:
FlickrBrandCamerasActionHandler implements BentenActionHandler { @Override public BentenHandlerResponse handle(BentenMessage bentenMessage) { BentenHandlerResponse handlerResponse = new BentenHandlerResponse(); String brandName = BentenMessageHelper.getParameterAsString(bentenMessage, FlickrActionParamaters.PARAMETER_BRAND_NAME); try { List<Camera> result = bentenFlickrClient.getBrandCameras(brandName); handlerResponse.setBentenSlackResponse(SlackFlickrMessageRenderer.renderList(result)); } catch (BentenFlickrException e) { BentenSlackResponse bentenSlackResponse = new BentenSlackResponse(); bentenSlackResponse.setSlackText(String.format("No cameras found for %s", brandName)); handlerResponse.setBentenSlackResponse(bentenSlackResponse); } return handlerResponse; }  @Override BentenHandlerResponse handle(BentenMessage bentenMessage);  }### Answer:
@Test public void testPopulatedRequest() { List<Camera> mockResults = FlickrResultBuilder.getCamerasFromJSON("camera-by-brand.json"); Mockito.when(bentenFlickrClient.getBrandCameras("Apple")).thenReturn(mockResults); BentenMessage params = FlickrMessageBuilder.constructBrandCamerasMessage("Apple"); BentenHandlerResponse response = flickrBrandCamerasActionHandler.handle(params); Assert.isTrue(response.getBentenSlackResponse().getSlackText().split("\n").length == 4, "Should have 4 lines of text"); }
@Test public void testErrorRequest() { Mockito.when(bentenFlickrClient.getBrandCameras("Apple")).thenThrow(new BentenFlickrException("error")); BentenMessage params = FlickrMessageBuilder.constructBrandCamerasMessage("Apple"); BentenHandlerResponse response = flickrBrandCamerasActionHandler.handle(params); Assert.hasText(response.getBentenSlackResponse().getSlackText(), "Should have slack message"); }
@Test public void testEmptyRequest() { Mockito.when(bentenFlickrClient.getBrandCameras("Apple")).thenReturn(new ArrayList<>()); BentenMessage params = FlickrMessageBuilder.constructBrandCamerasMessage("Apple"); BentenHandlerResponse response = flickrBrandCamerasActionHandler.handle(params); Assert.hasText(response.getBentenSlackResponse().getSlackText(), "Should have slack message"); }