@Test public void testHandleRequestInvalidIssue() throws InterruptedException { String issueKey = TestHelper.createStory(bentenJiraClient); TestHelper.updateAssigneeAndReporter(bentenJiraClient,issueKey); JsonElement status = new JsonPrimitive("Closed"); JsonElement currentuser = new JsonPrimitive(TestHelper.assigneeName); Thread.sleep(500); BentenHandlerResponse bentenHandlerResponse = jiraTransitionIssueActionHandler.handle(MessageBuilder.constructBentenTransitionIssueMessage(new JsonPrimitive("INVALID-1"),status,currentuser)); Thread.sleep(1000); Assert.assertNotNull(bentenHandlerResponse.getBentenSlackResponse()); Assert.assertNotNull(bentenHandlerResponse.getBentenSlackResponse().getSlackText()); Assert.assertTrue(bentenHandlerResponse.getBentenSlackResponse().getSlackText().contains("Issue Does Not Exist")); }
public BentenHandlerResponse handle(BentenMessage bentenMessage) { String issueKey = BentenMessageHelper.getParameterAsString(bentenMessage,JiraActionParameters.PARAMETER_ISSUE_KEY); String status = BentenMessageHelper.getParameterAsString(bentenMessage,JiraActionParameters.PARAMETER_STATUS); String assigneeName = BentenMessageHelper.getParameterAsString(bentenMessage, SlackConstants.CURRENT_USER); List<Transition> transitions = bentenJiraClient.possibleTransitions(issueKey); Transition toTransition = matchingTransition(status,transitions); BentenHandlerResponse bentenHandlerResponse = new BentenHandlerResponse(); if(toTransition==null){ bentenHandlerResponse.setBentenSlackResponse(SlackMessageRenderer.possibleTransitionsMessage(issueKey,status,possibleTransitonValues(transitions))); return bentenHandlerResponse; } User assignee = new User(); assignee.setName(assigneeName); try { bentenJiraClient.transition(issueKey,toTransition); bentenJiraClient.possibleTransitions(issueKey); bentenJiraClient.assignIssueToUser(issueKey,assignee); bentenHandlerResponse .setBentenSlackResponse(SlackMessageRenderer.transitionMessage(issueKey, status)); }catch(BentenJiraException e){ bentenHandlerResponse .setBentenSlackResponse(SlackMessageRenderer.errorMessage(e.getMessage().substring(e.getMessage().lastIndexOf(":")+1))); } return bentenHandlerResponse; }
JiraTransitionIssueActionHandler implements BentenActionHandler { public BentenHandlerResponse handle(BentenMessage bentenMessage) { String issueKey = BentenMessageHelper.getParameterAsString(bentenMessage,JiraActionParameters.PARAMETER_ISSUE_KEY); String status = BentenMessageHelper.getParameterAsString(bentenMessage,JiraActionParameters.PARAMETER_STATUS); String assigneeName = BentenMessageHelper.getParameterAsString(bentenMessage, SlackConstants.CURRENT_USER); List<Transition> transitions = bentenJiraClient.possibleTransitions(issueKey); Transition toTransition = matchingTransition(status,transitions); BentenHandlerResponse bentenHandlerResponse = new BentenHandlerResponse(); if(toTransition==null){ bentenHandlerResponse.setBentenSlackResponse(SlackMessageRenderer.possibleTransitionsMessage(issueKey,status,possibleTransitonValues(transitions))); return bentenHandlerResponse; } User assignee = new User(); assignee.setName(assigneeName); try { bentenJiraClient.transition(issueKey,toTransition); bentenJiraClient.possibleTransitions(issueKey); bentenJiraClient.assignIssueToUser(issueKey,assignee); bentenHandlerResponse .setBentenSlackResponse(SlackMessageRenderer.transitionMessage(issueKey, status)); }catch(BentenJiraException e){ bentenHandlerResponse .setBentenSlackResponse(SlackMessageRenderer.errorMessage(e.getMessage().substring(e.getMessage().lastIndexOf(":")+1))); } return bentenHandlerResponse; } }
JiraTransitionIssueActionHandler implements BentenActionHandler { public BentenHandlerResponse handle(BentenMessage bentenMessage) { String issueKey = BentenMessageHelper.getParameterAsString(bentenMessage,JiraActionParameters.PARAMETER_ISSUE_KEY); String status = BentenMessageHelper.getParameterAsString(bentenMessage,JiraActionParameters.PARAMETER_STATUS); String assigneeName = BentenMessageHelper.getParameterAsString(bentenMessage, SlackConstants.CURRENT_USER); List<Transition> transitions = bentenJiraClient.possibleTransitions(issueKey); Transition toTransition = matchingTransition(status,transitions); BentenHandlerResponse bentenHandlerResponse = new BentenHandlerResponse(); if(toTransition==null){ bentenHandlerResponse.setBentenSlackResponse(SlackMessageRenderer.possibleTransitionsMessage(issueKey,status,possibleTransitonValues(transitions))); return bentenHandlerResponse; } User assignee = new User(); assignee.setName(assigneeName); try { bentenJiraClient.transition(issueKey,toTransition); bentenJiraClient.possibleTransitions(issueKey); bentenJiraClient.assignIssueToUser(issueKey,assignee); bentenHandlerResponse .setBentenSlackResponse(SlackMessageRenderer.transitionMessage(issueKey, status)); }catch(BentenJiraException e){ bentenHandlerResponse .setBentenSlackResponse(SlackMessageRenderer.errorMessage(e.getMessage().substring(e.getMessage().lastIndexOf(":")+1))); } return bentenHandlerResponse; }  }
JiraTransitionIssueActionHandler implements BentenActionHandler { public BentenHandlerResponse handle(BentenMessage bentenMessage) { String issueKey = BentenMessageHelper.getParameterAsString(bentenMessage,JiraActionParameters.PARAMETER_ISSUE_KEY); String status = BentenMessageHelper.getParameterAsString(bentenMessage,JiraActionParameters.PARAMETER_STATUS); String assigneeName = BentenMessageHelper.getParameterAsString(bentenMessage, SlackConstants.CURRENT_USER); List<Transition> transitions = bentenJiraClient.possibleTransitions(issueKey); Transition toTransition = matchingTransition(status,transitions); BentenHandlerResponse bentenHandlerResponse = new BentenHandlerResponse(); if(toTransition==null){ bentenHandlerResponse.setBentenSlackResponse(SlackMessageRenderer.possibleTransitionsMessage(issueKey,status,possibleTransitonValues(transitions))); return bentenHandlerResponse; } User assignee = new User(); assignee.setName(assigneeName); try { bentenJiraClient.transition(issueKey,toTransition); bentenJiraClient.possibleTransitions(issueKey); bentenJiraClient.assignIssueToUser(issueKey,assignee); bentenHandlerResponse .setBentenSlackResponse(SlackMessageRenderer.transitionMessage(issueKey, status)); }catch(BentenJiraException e){ bentenHandlerResponse .setBentenSlackResponse(SlackMessageRenderer.errorMessage(e.getMessage().substring(e.getMessage().lastIndexOf(":")+1))); } return bentenHandlerResponse; }  BentenHandlerResponse handle(BentenMessage bentenMessage); }
JiraTransitionIssueActionHandler implements BentenActionHandler { public BentenHandlerResponse handle(BentenMessage bentenMessage) { String issueKey = BentenMessageHelper.getParameterAsString(bentenMessage,JiraActionParameters.PARAMETER_ISSUE_KEY); String status = BentenMessageHelper.getParameterAsString(bentenMessage,JiraActionParameters.PARAMETER_STATUS); String assigneeName = BentenMessageHelper.getParameterAsString(bentenMessage, SlackConstants.CURRENT_USER); List<Transition> transitions = bentenJiraClient.possibleTransitions(issueKey); Transition toTransition = matchingTransition(status,transitions); BentenHandlerResponse bentenHandlerResponse = new BentenHandlerResponse(); if(toTransition==null){ bentenHandlerResponse.setBentenSlackResponse(SlackMessageRenderer.possibleTransitionsMessage(issueKey,status,possibleTransitonValues(transitions))); return bentenHandlerResponse; } User assignee = new User(); assignee.setName(assigneeName); try { bentenJiraClient.transition(issueKey,toTransition); bentenJiraClient.possibleTransitions(issueKey); bentenJiraClient.assignIssueToUser(issueKey,assignee); bentenHandlerResponse .setBentenSlackResponse(SlackMessageRenderer.transitionMessage(issueKey, status)); }catch(BentenJiraException e){ bentenHandlerResponse .setBentenSlackResponse(SlackMessageRenderer.errorMessage(e.getMessage().substring(e.getMessage().lastIndexOf(":")+1))); } return bentenHandlerResponse; }  BentenHandlerResponse handle(BentenMessage bentenMessage);  }