@Test(expected = NullPointerException.class) public void testParseUsernameWithoutTheKeyUsernameInTheJSON() { githubRequest = RequestValues.getRequest10(); hook = new JiraServiceHook(); hook.setGithubRequest(githubRequest); hook.convertGithubRequestToJson(); hook.parseGithubJson(); }
@Test(expected = NoSuchElementException.class) public void testParseUsernameWithoutTheKeyMessageInTheJSON() { githubRequest = RequestValues.getRequest9(); hook = new JiraServiceHook(); hook.setGithubRequest(githubRequest); hook.convertGithubRequestToJson(); hook.parseGithubJson(); }
@Test public void testParseUsernameWithAValidUsername() { String expected = "bennyn"; String result = null; githubRequest = RequestValues.getRequest1(); hook = new JiraServiceHook(); hook.setGithubRequest(githubRequest); hook.convertGithubRequestToJson(); hook.parseGithubJson(); result = hook.getUsername(); assertEquals("Test if a username can be parsed from a github request.", expected, result); }
@Test public void testParseProjectVersion() throws JiraButlerException { String expected = "master"; String result = null; githubRequest = RequestValues.getRequest1(); hook = new JiraServiceHook(githubRequest); hook.convertGithubRequestToJson(); hook.parseGithubJson(); result = hook.getJiraProjectVersion(); assertEquals( "Test if a JIRA project version can be parsed from a github request.", expected, result); }
@Test public void testToString() throws JiraButlerException { String expected = "Project version: master\nJIRA Key: SWQ-11\nUser: bennyn\nCommit message: Cobertura inside!\n"; String result = null; githubRequest = RequestValues.getRequest1(); hook = new JiraServiceHook(githubRequest); hook.convertGithubRequestToJson(); hook.parseGithubJson(); result = hook.toString(); assertEquals("Test if toString() method works correctly.", expected, result); }
@Test public void testParseValidMessage() throws JiraButlerException { String expected = "Cobertura inside!"; String result = null; githubRequest = RequestValues.getRequest1(); hook = new JiraServiceHook(githubRequest); hook.convertGithubRequestToJson(); hook.parseGithubJson(); result = hook.getGitCommitMessage(); assertEquals( "Test if a message with a valid JIRA issue key can be parsed from a github request.", expected, result); }
@Test public void testParseInvalidMessageWithoutIssueKey() throws JiraButlerException { String expected = null; String result = null; githubRequest = RequestValues.getRequest5(); hook = new JiraServiceHook(githubRequest); hook.convertGithubRequestToJson(); hook.parseGithubJson(); result = hook.getJiraIssueKey(); assertEquals( "Test if a message without a JIRA issue key can be parsed from a github request.", expected, result); }