/**
   * TODO DOCUMENT ME!
   *
   * @throws Exception
   */
  @Test
  public void testMentionedInCommit() throws Exception {
    MentionedInCommitStrategy strategy = new MentionedInCommitStrategy();

    ChangeLogSet mockChangeSet =
        MockChangeLogUtil.mockChangeLogSet(
            new MockChangeLogUtil.MockChangeLog("FOO-101 first", "knork"),
            new MockChangeLogUtil.MockChangeLog("[BAR-102] with square brackets", "zark"),
            new MockChangeLogUtil.MockChangeLog("Fixed FOO-103 inbetween", "flarp"),
            new MockChangeLogUtil.MockChangeLog("Fixed BAR-104typo", "narf"),
            new MockChangeLogUtil.MockChangeLog(
                "FOO-101 again but, because FOO-101 was invalid, but FOO-105 not", "knork"),
            new MockChangeLogUtil.MockChangeLog("Invalid [foo-103] lowercase", "flarp"),
            new MockChangeLogUtil.MockChangeLog("No Valid Ticket", "build robot"));
    AbstractBuild mockBuild = mock(AbstractBuild.class);
    when(mockBuild.getChangeSet()).thenReturn(mockChangeSet);

    List<JiraCommit> commits =
        strategy.getJiraCommits(
            mockBuild, new StreamBuildListener(System.out, Charset.defaultCharset()));

    assertEquals(commits.size(), 6);

    assertThat(
        commits, hasItem(Matchers.<JiraCommit>hasProperty("jiraTicket", equalTo("FOO-101"))));
    assertThat(
        commits, hasItem(Matchers.<JiraCommit>hasProperty("jiraTicket", equalTo("BAR-102"))));
    assertThat(
        commits, hasItem(Matchers.<JiraCommit>hasProperty("jiraTicket", equalTo("FOO-103"))));
    assertThat(
        commits, hasItem(Matchers.<JiraCommit>hasProperty("jiraTicket", equalTo("BAR-104"))));
    assertThat(
        commits, hasItem(Matchers.<JiraCommit>hasProperty("jiraTicket", equalTo("FOO-105"))));
  }
  @Test
  public void testInvokeOperations() {
    IssueStrategyExtension mockStrategy = mock(IssueStrategyExtension.class);
    JiraOperationExtension mockOperation = mock(JiraOperationExtension.class);
    Descriptor mockDescriptor = mock(Descriptor.class);
    when(mockDescriptor.getDisplayName()).thenReturn("Mock descriptor");
    when(mockOperation.getDescriptor()).thenReturn(mockDescriptor);
    JiraExtBuildStep builder = new JiraExtBuildStep(mockStrategy, Arrays.asList(mockOperation));
    List<JiraCommit> commits =
        Arrays.asList(
            new JiraCommit(
                "JENKINS-101", MockChangeLogUtil.mockChangeLogSetEntry("example ticket")));

    when(mockStrategy.getJiraCommits(any(AbstractBuild.class), any(BuildListener.class)))
        .thenReturn(commits);

    assertTrue(
        builder.perform(
            mock(AbstractBuild.class), mock(Launcher.class), new StreamBuildListener(System.out)));
    verify(mockOperation)
        .perform(
            eq(commits), any(AbstractBuild.class), any(Launcher.class), any(BuildListener.class));
  }