@Test @Ignore public void testHandleRequest(){ BentenMessage bentenMessage = new BentenMessage(); JsonElement boardName = new JsonPrimitive("Combined_Services_Team_view"); JsonElement noOfSprints = new JsonPrimitive("1"); HashMap<String, JsonElement> parameters = new HashMap<>(); parameters.put(JiraActionParameters.PARAMETER_BOARD_NAME,boardName); parameters.put(JiraActionParameters.PARAMETER_NO_OF_SPRINTS,noOfSprints); bentenMessage.setParameters(parameters); BentenHandlerResponse bentenHandlerResponse = jiraCycleTimeActionHandler.handle(bentenMessage); Assert.assertNotNull(bentenHandlerResponse.getBentenHtmlResponse()); }
public BentenHandlerResponse handle(BentenMessage bentenMessage) { String boardName = BentenMessageHelper.getParameterAsString(bentenMessage, JiraActionParameters.PARAMETER_BOARD_NAME); String noOfSprints = BentenMessageHelper.getParameterAsString(bentenMessage, JiraActionParameters.PARAMETER_NO_OF_SPRINTS); BentenHandlerResponse bentenHandlerResponse = new BentenHandlerResponse(); try { List<Board> boards = bentenJiraClient.getBoardsByName(boardName); List<Sprint> sprints = bentenJiraClient.getSprintsByBoardId(boards.get(0).getId()); Collections.reverse(sprints); List<Sprint> closedSprints = sprints.stream() .filter(sprint -> sprint.getState().equals("CLOSED")) .collect(Collectors.toList()); closedSprints = closedSprints.subList(0, Integer.parseInt(noOfSprints)); List<SprintCycleTime> sprintCycleTimes = closedSprints.stream().map((sprint) -> { return cycleTime(sprint, boards.get(0)); }).collect(Collectors.toList()); List<Table> cycleTimeTables = null; cycleTimeTables = CycleTimeTableConverter.cycleTimeReportAsTables(sprintCycleTimes); List<String> htmlTables = cycleTimeTables.stream().map((cycleTimeTable) -> { return TableToHtmlConverter.convertTableToHtmlTable(cycleTimeTable); }).collect(Collectors.toList()); StringBuilder htmlResponse = new StringBuilder(""); for (String htmlTable : htmlTables) { htmlResponse.append(htmlTable); } BentenHtmlResponse bentenHtmlResponse = new BentenHtmlResponse(); bentenHtmlResponse.setHtml(htmlResponse.toString()); bentenHandlerResponse .setBentenHtmlResponse(bentenHtmlResponse); } catch (BentenJiraException e) { bentenHandlerResponse .setBentenSlackResponse(SlackMessageRenderer.errorMessage(e.getMessage().substring(e.getMessage().lastIndexOf(":") + 1))); } catch (Exception e) { throw new BentenJiraException(e.getMessage()); } return bentenHandlerResponse; }
JiraCycleTimeActionHandler implements BentenActionHandler { public BentenHandlerResponse handle(BentenMessage bentenMessage) { String boardName = BentenMessageHelper.getParameterAsString(bentenMessage, JiraActionParameters.PARAMETER_BOARD_NAME); String noOfSprints = BentenMessageHelper.getParameterAsString(bentenMessage, JiraActionParameters.PARAMETER_NO_OF_SPRINTS); BentenHandlerResponse bentenHandlerResponse = new BentenHandlerResponse(); try { List<Board> boards = bentenJiraClient.getBoardsByName(boardName); List<Sprint> sprints = bentenJiraClient.getSprintsByBoardId(boards.get(0).getId()); Collections.reverse(sprints); List<Sprint> closedSprints = sprints.stream() .filter(sprint -> sprint.getState().equals("CLOSED")) .collect(Collectors.toList()); closedSprints = closedSprints.subList(0, Integer.parseInt(noOfSprints)); List<SprintCycleTime> sprintCycleTimes = closedSprints.stream().map((sprint) -> { return cycleTime(sprint, boards.get(0)); }).collect(Collectors.toList()); List<Table> cycleTimeTables = null; cycleTimeTables = CycleTimeTableConverter.cycleTimeReportAsTables(sprintCycleTimes); List<String> htmlTables = cycleTimeTables.stream().map((cycleTimeTable) -> { return TableToHtmlConverter.convertTableToHtmlTable(cycleTimeTable); }).collect(Collectors.toList()); StringBuilder htmlResponse = new StringBuilder(""); for (String htmlTable : htmlTables) { htmlResponse.append(htmlTable); } BentenHtmlResponse bentenHtmlResponse = new BentenHtmlResponse(); bentenHtmlResponse.setHtml(htmlResponse.toString()); bentenHandlerResponse .setBentenHtmlResponse(bentenHtmlResponse); } catch (BentenJiraException e) { bentenHandlerResponse .setBentenSlackResponse(SlackMessageRenderer.errorMessage(e.getMessage().substring(e.getMessage().lastIndexOf(":") + 1))); } catch (Exception e) { throw new BentenJiraException(e.getMessage()); } return bentenHandlerResponse; } }
JiraCycleTimeActionHandler implements BentenActionHandler { public BentenHandlerResponse handle(BentenMessage bentenMessage) { String boardName = BentenMessageHelper.getParameterAsString(bentenMessage, JiraActionParameters.PARAMETER_BOARD_NAME); String noOfSprints = BentenMessageHelper.getParameterAsString(bentenMessage, JiraActionParameters.PARAMETER_NO_OF_SPRINTS); BentenHandlerResponse bentenHandlerResponse = new BentenHandlerResponse(); try { List<Board> boards = bentenJiraClient.getBoardsByName(boardName); List<Sprint> sprints = bentenJiraClient.getSprintsByBoardId(boards.get(0).getId()); Collections.reverse(sprints); List<Sprint> closedSprints = sprints.stream() .filter(sprint -> sprint.getState().equals("CLOSED")) .collect(Collectors.toList()); closedSprints = closedSprints.subList(0, Integer.parseInt(noOfSprints)); List<SprintCycleTime> sprintCycleTimes = closedSprints.stream().map((sprint) -> { return cycleTime(sprint, boards.get(0)); }).collect(Collectors.toList()); List<Table> cycleTimeTables = null; cycleTimeTables = CycleTimeTableConverter.cycleTimeReportAsTables(sprintCycleTimes); List<String> htmlTables = cycleTimeTables.stream().map((cycleTimeTable) -> { return TableToHtmlConverter.convertTableToHtmlTable(cycleTimeTable); }).collect(Collectors.toList()); StringBuilder htmlResponse = new StringBuilder(""); for (String htmlTable : htmlTables) { htmlResponse.append(htmlTable); } BentenHtmlResponse bentenHtmlResponse = new BentenHtmlResponse(); bentenHtmlResponse.setHtml(htmlResponse.toString()); bentenHandlerResponse .setBentenHtmlResponse(bentenHtmlResponse); } catch (BentenJiraException e) { bentenHandlerResponse .setBentenSlackResponse(SlackMessageRenderer.errorMessage(e.getMessage().substring(e.getMessage().lastIndexOf(":") + 1))); } catch (Exception e) { throw new BentenJiraException(e.getMessage()); } return bentenHandlerResponse; }  }
JiraCycleTimeActionHandler implements BentenActionHandler { public BentenHandlerResponse handle(BentenMessage bentenMessage) { String boardName = BentenMessageHelper.getParameterAsString(bentenMessage, JiraActionParameters.PARAMETER_BOARD_NAME); String noOfSprints = BentenMessageHelper.getParameterAsString(bentenMessage, JiraActionParameters.PARAMETER_NO_OF_SPRINTS); BentenHandlerResponse bentenHandlerResponse = new BentenHandlerResponse(); try { List<Board> boards = bentenJiraClient.getBoardsByName(boardName); List<Sprint> sprints = bentenJiraClient.getSprintsByBoardId(boards.get(0).getId()); Collections.reverse(sprints); List<Sprint> closedSprints = sprints.stream() .filter(sprint -> sprint.getState().equals("CLOSED")) .collect(Collectors.toList()); closedSprints = closedSprints.subList(0, Integer.parseInt(noOfSprints)); List<SprintCycleTime> sprintCycleTimes = closedSprints.stream().map((sprint) -> { return cycleTime(sprint, boards.get(0)); }).collect(Collectors.toList()); List<Table> cycleTimeTables = null; cycleTimeTables = CycleTimeTableConverter.cycleTimeReportAsTables(sprintCycleTimes); List<String> htmlTables = cycleTimeTables.stream().map((cycleTimeTable) -> { return TableToHtmlConverter.convertTableToHtmlTable(cycleTimeTable); }).collect(Collectors.toList()); StringBuilder htmlResponse = new StringBuilder(""); for (String htmlTable : htmlTables) { htmlResponse.append(htmlTable); } BentenHtmlResponse bentenHtmlResponse = new BentenHtmlResponse(); bentenHtmlResponse.setHtml(htmlResponse.toString()); bentenHandlerResponse .setBentenHtmlResponse(bentenHtmlResponse); } catch (BentenJiraException e) { bentenHandlerResponse .setBentenSlackResponse(SlackMessageRenderer.errorMessage(e.getMessage().substring(e.getMessage().lastIndexOf(":") + 1))); } catch (Exception e) { throw new BentenJiraException(e.getMessage()); } return bentenHandlerResponse; }  BentenHandlerResponse handle(BentenMessage bentenMessage); SprintCycleTime cycleTime(Sprint sprint, Board board); }
JiraCycleTimeActionHandler implements BentenActionHandler { public BentenHandlerResponse handle(BentenMessage bentenMessage) { String boardName = BentenMessageHelper.getParameterAsString(bentenMessage, JiraActionParameters.PARAMETER_BOARD_NAME); String noOfSprints = BentenMessageHelper.getParameterAsString(bentenMessage, JiraActionParameters.PARAMETER_NO_OF_SPRINTS); BentenHandlerResponse bentenHandlerResponse = new BentenHandlerResponse(); try { List<Board> boards = bentenJiraClient.getBoardsByName(boardName); List<Sprint> sprints = bentenJiraClient.getSprintsByBoardId(boards.get(0).getId()); Collections.reverse(sprints); List<Sprint> closedSprints = sprints.stream() .filter(sprint -> sprint.getState().equals("CLOSED")) .collect(Collectors.toList()); closedSprints = closedSprints.subList(0, Integer.parseInt(noOfSprints)); List<SprintCycleTime> sprintCycleTimes = closedSprints.stream().map((sprint) -> { return cycleTime(sprint, boards.get(0)); }).collect(Collectors.toList()); List<Table> cycleTimeTables = null; cycleTimeTables = CycleTimeTableConverter.cycleTimeReportAsTables(sprintCycleTimes); List<String> htmlTables = cycleTimeTables.stream().map((cycleTimeTable) -> { return TableToHtmlConverter.convertTableToHtmlTable(cycleTimeTable); }).collect(Collectors.toList()); StringBuilder htmlResponse = new StringBuilder(""); for (String htmlTable : htmlTables) { htmlResponse.append(htmlTable); } BentenHtmlResponse bentenHtmlResponse = new BentenHtmlResponse(); bentenHtmlResponse.setHtml(htmlResponse.toString()); bentenHandlerResponse .setBentenHtmlResponse(bentenHtmlResponse); } catch (BentenJiraException e) { bentenHandlerResponse .setBentenSlackResponse(SlackMessageRenderer.errorMessage(e.getMessage().substring(e.getMessage().lastIndexOf(":") + 1))); } catch (Exception e) { throw new BentenJiraException(e.getMessage()); } return bentenHandlerResponse; }  BentenHandlerResponse handle(BentenMessage bentenMessage); SprintCycleTime cycleTime(Sprint sprint, Board board);  }