@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"); }
@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; }
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; } }
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; }  }
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); }
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);  }