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);
}
}
}
Aggregations