Search in sources :

Example 6 with Issue

use of org.apache.maven.plugins.issues.Issue in project maven-plugins by apache.

the class IssueUtilsTestCase method testFilterIssuesWithVersionPrefix.

public void testFilterIssuesWithVersionPrefix() {
    Issue issue_1;
    issue_1 = new Issue();
    issue_1.setId("1");
    issue_1.addFixVersion("myPrefix-1.0");
    Issue issue_2;
    issue_2 = new Issue();
    issue_2.setId("2");
    issue_2.addFixVersion("1.0");
    List<Issue> issueList = new ArrayList<Issue>();
    issueList.add(issue_1);
    issueList.add(issue_2);
    List<Issue> filteredIssues;
    try {
        filteredIssues = IssueUtils.filterIssuesWithVersionPrefix(issueList, null);
        assertEquals(2, filteredIssues.size());
        filteredIssues = IssueUtils.filterIssuesWithVersionPrefix(issueList, "");
        assertEquals(2, filteredIssues.size());
        filteredIssues = IssueUtils.filterIssuesWithVersionPrefix(issueList, "myPrefix-");
        assertEquals(1, filteredIssues.size());
    } catch (MojoExecutionException e) {
        fail(e.getMessage());
    }
    try {
        IssueUtils.filterIssuesWithVersionPrefix(issueList, "yourPrefix-");
        fail("No issues should be found.");
    } catch (MojoExecutionException e) {
    // Expected
    }
}
Also used : Issue(org.apache.maven.plugins.issues.Issue) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ArrayList(java.util.ArrayList)

Example 7 with Issue

use of org.apache.maven.plugins.issues.Issue in project maven-plugins by apache.

the class GitHubDownloader method createIssue.

protected Issue createIssue(org.eclipse.egit.github.core.Issue githubIssue) {
    Issue issue = new Issue();
    issue.setKey(String.valueOf(githubIssue.getNumber()));
    issue.setId(String.valueOf(githubIssue.getNumber()));
    issue.setLink(this.githubIssueURL + githubIssue.getNumber());
    issue.setCreated(githubIssue.getCreatedAt());
    issue.setUpdated(githubIssue.getUpdatedAt());
    if (githubIssue.getAssignee() != null) {
        if (githubIssue.getAssignee().getName() != null) {
            issue.setAssignee(githubIssue.getAssignee().getName());
        } else {
            issue.setAssignee(githubIssue.getAssignee().getLogin());
        }
    }
    issue.setTitle(githubIssue.getTitle());
    issue.setSummary(githubIssue.getTitle());
    if (githubIssue.getMilestone() != null) {
        issue.addFixVersion(githubIssue.getMilestone().getTitle());
    }
    issue.setReporter(githubIssue.getUser().getLogin());
    if (githubIssue.getClosedAt() != null) {
        issue.setStatus("closed");
    } else {
        issue.setStatus("open");
    }
    List<Label> labels = githubIssue.getLabels();
    if (labels != null && !labels.isEmpty()) {
        issue.setType(labels.get(0).getName());
    }
    return issue;
}
Also used : Issue(org.apache.maven.plugins.issues.Issue) Label(org.eclipse.egit.github.core.Label)

Example 8 with Issue

use of org.apache.maven.plugins.issues.Issue in project maven-plugins by apache.

the class GitHubMojo method executeReport.

@Override
protected void executeReport(Locale locale) throws MavenReportException {
    // Validate parameters
    List<Integer> columnIds = IssuesReportHelper.getColumnIds(columnNames, githubColumns);
    if (columnIds.size() == 0) {
        // This can happen if the user has configured column names and they are all invalid
        throw new MavenReportException("maven-changes-plugin: None of the configured columnNames '" + columnNames + "' are valid.");
    }
    try {
        // Download issues
        GitHubDownloader issueDownloader = new GitHubDownloader(project, githubAPIScheme, githubAPIPort, includeOpenIssues, onlyMilestoneIssues);
        issueDownloader.configureAuthentication(settingsDecrypter, githubAPIServerId, settings, getLog());
        List<Issue> issueList = issueDownloader.getIssueList();
        if (onlyCurrentVersion) {
            issueList = IssueUtils.getIssuesForVersion(issueList, project.getVersion());
            getLog().info("The GitHub Report will contain issues only for the current version.");
        }
        // Generate the report
        IssuesReportGenerator report = new IssuesReportGenerator(IssuesReportHelper.toIntArray(columnIds));
        if (issueList.isEmpty()) {
            report.doGenerateEmptyReport(getBundle(locale), getSink());
            getLog().warn("No issue was matched.");
        } else {
            report.doGenerateReport(getBundle(locale), getSink(), issueList);
        }
    } catch (MalformedURLException e) {
        // Rethrow this error so that the build fails
        throw new MavenReportException("The Github URL is incorrect.");
    } catch (Exception e) {
        throw new MavenReportException(e.getMessage(), e);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) Issue(org.apache.maven.plugins.issues.Issue) IssuesReportGenerator(org.apache.maven.plugins.issues.IssuesReportGenerator) MalformedURLException(java.net.MalformedURLException) MavenReportException(org.apache.maven.reporting.MavenReportException) MavenReportException(org.apache.maven.reporting.MavenReportException)

Example 9 with Issue

use of org.apache.maven.plugins.issues.Issue in project maven-plugins by apache.

the class JiraXML method startElement.

public void startElement(String namespaceURI, String sName, String qName, Attributes attrs) throws SAXException {
    if (qName.equals("item")) {
        issue = new Issue();
        currentParent = "item";
    } else if (qName.equals("key")) {
        String id = attrs.getValue("id");
        if (id != null) {
            issue.setId(id.trim());
        }
    } else if (qName.equals("build-info")) {
        currentParent = "build-info";
    }
}
Also used : Issue(org.apache.maven.plugins.issues.Issue)

Example 10 with Issue

use of org.apache.maven.plugins.issues.Issue in project maven-plugins by apache.

the class IssueAdapterTest method testCustomIssueTypeMapping.

public void testCustomIssueTypeMapping() {
    IssueManagementSystem ims = new JIRAIssueManagmentSystem();
    ims.getIssueTypeMap().put("Story", IssueType.ADD);
    ims.getIssueTypeMap().put("Epic", IssueType.ADD);
    ims.getIssueTypeMap().put("Defect", IssueType.FIX);
    ims.getIssueTypeMap().put("Error", IssueType.FIX);
    IssueAdapter adapter = new IssueAdapter(ims);
    Issue issue = createIssue("TST-1", "Story");
    Action action = adapter.createAction(issue);
    assertEquals("add", action.getType());
    issue = createIssue("TST-2", "Epic");
    action = adapter.createAction(issue);
    assertEquals("add", action.getType());
    issue = createIssue("TST-3", "Error");
    action = adapter.createAction(issue);
    assertEquals("fix", action.getType());
    issue = createIssue("TST-4", "Defect");
    action = adapter.createAction(issue);
    assertEquals("fix", action.getType());
    // Test the default mapping for "update" hasn't been overridden
    issue = createIssue("TST-5", "Improvement");
    action = adapter.createAction(issue);
    assertEquals("update", action.getType());
}
Also used : IssueAdapter(org.apache.maven.plugins.changes.IssueAdapter) Action(org.apache.maven.plugins.changes.model.Action) Issue(org.apache.maven.plugins.issues.Issue) IssueManagementSystem(org.apache.maven.plugins.issues.IssueManagementSystem) JIRAIssueManagmentSystem(org.apache.maven.plugins.jira.JIRAIssueManagmentSystem)

Aggregations

Issue (org.apache.maven.plugins.issues.Issue)17 ArrayList (java.util.ArrayList)4 Action (org.apache.maven.plugins.changes.model.Action)4 JIRAIssueManagmentSystem (org.apache.maven.plugins.jira.JIRAIssueManagmentSystem)4 MalformedURLException (java.net.MalformedURLException)3 IssueAdapter (org.apache.maven.plugins.changes.IssueAdapter)3 IssuesReportGenerator (org.apache.maven.plugins.issues.IssuesReportGenerator)3 MavenReportException (org.apache.maven.reporting.MavenReportException)3 HashMap (java.util.HashMap)2 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2 IssueManagementSystem (org.apache.maven.plugins.issues.IssueManagementSystem)2 XmlRpcException (org.apache.xmlrpc.XmlRpcException)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 File (java.io.File)1 URL (java.net.URL)1 Map (java.util.Map)1 IssueManagement (org.apache.maven.model.IssueManagement)1 Release (org.apache.maven.plugins.changes.model.Release)1 AbstractJiraDownloader (org.apache.maven.plugins.jira.AbstractJiraDownloader)1 AdaptiveJiraDownloader (org.apache.maven.plugins.jira.AdaptiveJiraDownloader)1