Ejemplo n.º 1
0
 @Test(expected = NullPointerException.class)
 public void testParseUsernameWithoutTheKeyUsernameInTheJSON() {
   githubRequest = RequestValues.getRequest10();
   hook = new JiraServiceHook();
   hook.setGithubRequest(githubRequest);
   hook.convertGithubRequestToJson();
   hook.parseGithubJson();
 }
Ejemplo n.º 2
0
 @Test(expected = NoSuchElementException.class)
 public void testParseUsernameWithoutTheKeyMessageInTheJSON() {
   githubRequest = RequestValues.getRequest9();
   hook = new JiraServiceHook();
   hook.setGithubRequest(githubRequest);
   hook.convertGithubRequestToJson();
   hook.parseGithubJson();
 }
Ejemplo n.º 3
0
  @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);
  }
Ejemplo n.º 4
0
  @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);
  }
Ejemplo n.º 5
0
  @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);
  }
Ejemplo n.º 6
0
  @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);
  }
Ejemplo n.º 7
0
  @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);
  }