Search in sources :

Example 1 with Promise

use of com.atlassian.util.concurrent.Promise in project staf by simpleworks-gmbh.

the class TestFloFixVersion method addFixVersions.

public void addFixVersions(final List<FixVersion> fetchedFixedVersion, final String id) {
    if (Convert.isEmpty(fetchedFixedVersion)) {
        throw new IllegalArgumentException("fetchedFixedVersion can't be null or empty string.");
    }
    if (Convert.isEmpty(id)) {
        throw new IllegalArgumentException("id can't be null or empty string.");
    }
    try {
        final Promise<Issue> promise = jira.getIssue(id);
        final Issue issue = promise.claim();
        if (issue == null) {
            throw new RuntimeException("issue can't be null.");
        }
        final IssueInputBuilder issueBuilder = new IssueInputBuilder();
        List<Version> versions = new ArrayList<Version>();
        for (final FixVersion fixVersion : fetchedFixedVersion) {
            if (!versions.add(new Version(new URI(fixVersion.getSelf()), null, fixVersion.getName(), fixVersion.getDescription(), false, false, null))) {
                TestFloFixVersion.logger.error(String.format("can't add version '%s'.", fixVersion.getId()));
            }
        }
        issueBuilder.setFixVersions(versions);
        final IssueInput newIssue = issueBuilder.build();
        if (newIssue == null) {
            throw new IllegalArgumentException("newIssue can't be null or empty string.");
        }
        final Promise<Void> update = jira.updateIssue(id, newIssue);
        update.claim();
    } catch (Exception ex) {
        if (TestFloFixVersion.logger.isDebugEnabled()) {
            TestFloFixVersion.logger.debug(String.format("can't add fix version '%s' for testcase '%s'.", String.join(", ", fetchedFixedVersion.stream().map(v -> v.toString()).collect(Collectors.toList())), id), ex);
        }
    }
}
Also used : IssueRestClient(com.atlassian.jira.rest.client.api.IssueRestClient) SystemException(de.simpleworks.staf.commons.exceptions.SystemException) Issue(com.atlassian.jira.rest.client.api.domain.Issue) URL(java.net.URL) UtilsIO(de.simpleworks.staf.commons.utils.UtilsIO) ArrayList(java.util.ArrayList) IssueInput(com.atlassian.jira.rest.client.api.domain.input.IssueInput) Response(okhttp3.Response) Call(okhttp3.Call) URI(java.net.URI) FixVersion(de.simpleworks.staf.plugin.maven.testflo.commons.pojo.FixVersion) Convert(de.simpleworks.staf.commons.utils.Convert) ResponseBody(okhttp3.ResponseBody) Request(okhttp3.Request) JiraProperties(de.simpleworks.staf.module.jira.util.JiraProperties) IssueInputBuilder(com.atlassian.jira.rest.client.api.domain.input.IssueInputBuilder) JsonPath(com.jayway.jsonpath.JsonPath) Collectors(java.util.stream.Collectors) List(java.util.List) Promise(com.atlassian.util.concurrent.Promise) Logger(org.apache.logging.log4j.Logger) OkHttpClient(okhttp3.OkHttpClient) Version(com.atlassian.jira.rest.client.api.domain.Version) JSONArray(net.minidev.json.JSONArray) Assert(org.junit.Assert) LogManager(org.apache.logging.log4j.LogManager) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) FixVersion(de.simpleworks.staf.plugin.maven.testflo.commons.pojo.FixVersion) Issue(com.atlassian.jira.rest.client.api.domain.Issue) ArrayList(java.util.ArrayList) URI(java.net.URI) SystemException(de.simpleworks.staf.commons.exceptions.SystemException) IssueInput(com.atlassian.jira.rest.client.api.domain.input.IssueInput) FixVersion(de.simpleworks.staf.plugin.maven.testflo.commons.pojo.FixVersion) Version(com.atlassian.jira.rest.client.api.domain.Version) IssueInputBuilder(com.atlassian.jira.rest.client.api.domain.input.IssueInputBuilder)

Aggregations

IssueRestClient (com.atlassian.jira.rest.client.api.IssueRestClient)1 Issue (com.atlassian.jira.rest.client.api.domain.Issue)1 Version (com.atlassian.jira.rest.client.api.domain.Version)1 IssueInput (com.atlassian.jira.rest.client.api.domain.input.IssueInput)1 IssueInputBuilder (com.atlassian.jira.rest.client.api.domain.input.IssueInputBuilder)1 Promise (com.atlassian.util.concurrent.Promise)1 JsonPath (com.jayway.jsonpath.JsonPath)1 SystemException (de.simpleworks.staf.commons.exceptions.SystemException)1 Convert (de.simpleworks.staf.commons.utils.Convert)1 UtilsIO (de.simpleworks.staf.commons.utils.UtilsIO)1 JiraProperties (de.simpleworks.staf.module.jira.util.JiraProperties)1 FixVersion (de.simpleworks.staf.plugin.maven.testflo.commons.pojo.FixVersion)1 URI (java.net.URI)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 JSONArray (net.minidev.json.JSONArray)1 Call (okhttp3.Call)1 OkHttpClient (okhttp3.OkHttpClient)1