Search in sources :

Example 1 with SimpleIssue

use of io.syndesis.qe.issue.SimpleIssue in project syndesis-qe by syndesisio.

the class IssueHooksUtils method analyzeGithubIssues.

public static List<SimpleIssue> analyzeGithubIssues(List<String> githubIssues, Scenario scenario) {
    GitHubClient gitHubClient = getGitHubClient(scenario);
    List<SimpleIssue> issues = new ArrayList<>();
    if (gitHubClient == null) {
        return Collections.emptyList();
    }
    RepositoryService repositoryService = new RepositoryService(gitHubClient);
    IssueService issueService = new IssueService(gitHubClient);
    try {
        Repository repository = repositoryService.getRepository("syndesisio", "syndesis");
        for (String tag : githubIssues) {
            String issueNumber = tag.replaceFirst("^@gh-", "");
            Issue issue = issueService.getIssue(repository, issueNumber);
            issues.add(transformGithubIssue(issue, scenario));
        }
    } catch (IOException e) {
        log.error("Error while processing GitHub issues", e);
        scenario.attach("Error while processing GitHub issues".getBytes(), "text/plain", "ErrorMessage");
        e.printStackTrace();
    }
    return issues;
}
Also used : IssueService(org.eclipse.egit.github.core.service.IssueService) GitHubClient(org.eclipse.egit.github.core.client.GitHubClient) Repository(org.eclipse.egit.github.core.Repository) Issue(org.eclipse.egit.github.core.Issue) SimpleIssue(io.syndesis.qe.issue.SimpleIssue) SimpleIssue(io.syndesis.qe.issue.SimpleIssue) ArrayList(java.util.ArrayList) IOException(java.io.IOException) RepositoryService(org.eclipse.egit.github.core.service.RepositoryService)

Example 2 with SimpleIssue

use of io.syndesis.qe.issue.SimpleIssue in project syndesis-qe by syndesisio.

the class IssueHooksUtils method analyzeJiraIssues.

public static List<SimpleIssue> analyzeJiraIssues(List<String> jiraIssues, Scenario scenario) {
    List<SimpleIssue> issues = new ArrayList<>();
    JiraRestClient jiraClient = getJiraClient(scenario);
    if (jiraClient == null) {
        return Collections.emptyList();
    }
    IssueRestClient issueClient = jiraClient.getIssueClient();
    for (String tag : jiraIssues) {
        String issueName = tag.replaceFirst("^@", "");
        try {
            com.atlassian.jira.rest.client.api.domain.Issue issue = issueClient.getIssue(issueName).claim();
            issues.add(transformJiraIssue(issue));
        } catch (RestClientException e) {
            log.error("Couldn't obtain the Jira issue : {}", tag);
            scenario.attach("Error while processing Jira issues".getBytes(), "text/plain", "ErrorMessage");
            e.printStackTrace();
        }
    }
    return issues;
}
Also used : SimpleIssue(io.syndesis.qe.issue.SimpleIssue) ArrayList(java.util.ArrayList) JiraRestClient(com.atlassian.jira.rest.client.api.JiraRestClient) RestClientException(com.atlassian.jira.rest.client.api.RestClientException) IssueRestClient(com.atlassian.jira.rest.client.api.IssueRestClient)

Example 3 with SimpleIssue

use of io.syndesis.qe.issue.SimpleIssue in project syndesis-qe by syndesisio.

the class IssueHooks method embedIssues.

private void embedIssues(Scenario scenario, List<SimpleIssue> issues) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    ArrayNode array = mapper.createArrayNode();
    for (SimpleIssue issue : issues) {
        array.addPOJO(issue);
    }
    StringWriter sw = new StringWriter();
    mapper.writeValue(sw, array);
    scenario.attach(sw.toString().getBytes(), "application/x.issues+json", "Issues");
}
Also used : StringWriter(java.io.StringWriter) SimpleIssue(io.syndesis.qe.issue.SimpleIssue) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 4 with SimpleIssue

use of io.syndesis.qe.issue.SimpleIssue in project syndesis-qe by syndesisio.

the class IssueHooksUtils method transformGithubIssue.

private static SimpleIssue transformGithubIssue(Issue githubIssue, Scenario scenario) {
    SimpleIssue issue = new SimpleIssue();
    issue.setIssue(Integer.toString(githubIssue.getNumber()));
    issue.setUrl(githubIssue.getHtmlUrl());
    issue.setIssueSummary(githubIssue.getTitle());
    issue.setState(getGHIssueState(scenario, githubIssue));
    return issue;
}
Also used : SimpleIssue(io.syndesis.qe.issue.SimpleIssue)

Example 5 with SimpleIssue

use of io.syndesis.qe.issue.SimpleIssue in project syndesis-qe by syndesisio.

the class IssueHooksUtils method transformJiraIssue.

private static SimpleIssue transformJiraIssue(com.atlassian.jira.rest.client.api.domain.Issue jiraIssue) {
    SimpleIssue issue = new SimpleIssue();
    issue.setIssue(jiraIssue.getKey());
    issue.setUrl(getJiraIssueUrl(jiraIssue));
    issue.setIssueSummary(jiraIssue.getSummary());
    issue.setState(getJiraIssueState(jiraIssue));
    return issue;
}
Also used : SimpleIssue(io.syndesis.qe.issue.SimpleIssue)

Aggregations

SimpleIssue (io.syndesis.qe.issue.SimpleIssue)9 ArrayList (java.util.ArrayList)4 IOException (java.io.IOException)3 IssueRestClient (com.atlassian.jira.rest.client.api.IssueRestClient)1 JiraRestClient (com.atlassian.jira.rest.client.api.JiraRestClient)1 RestClientException (com.atlassian.jira.rest.client.api.RestClientException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 After (io.cucumber.java.After)1 Before (io.cucumber.java.Before)1 File (java.io.File)1 FileWriter (java.io.FileWriter)1 StringWriter (java.io.StringWriter)1 Issue (org.eclipse.egit.github.core.Issue)1 Repository (org.eclipse.egit.github.core.Repository)1 GitHubClient (org.eclipse.egit.github.core.client.GitHubClient)1 IssueService (org.eclipse.egit.github.core.service.IssueService)1 RepositoryService (org.eclipse.egit.github.core.service.RepositoryService)1