Skip to content
Permalink
Browse files

119: Support fetching Jira issues with only a partial id

Reviewed-by: ehelin
  • Loading branch information
Robin Westberg
Robin Westberg committed Oct 4, 2019
1 parent 5871660 commit c8b859f1eea86cc0aba6f62746daa6faf1350268
@@ -831,6 +831,25 @@ void issueInSummary(TestInfo testInfo) throws IOException {
assertFalse(pr.getBody().contains("My first issue"));
assertTrue(pr.getBody().contains("My second issue"));

// Use an invalid issue key
var issueKey = issue1.getId().replace("TEST", "BADPROJECT");
pr.setTitle(issueKey + ": This is a pull request");

// Check the status again
TestBotRunner.runPeriodicItems(checkBot);
assertFalse(pr.getBody().contains("My first issue"));
assertFalse(pr.getBody().contains("My second issue"));
assertTrue(pr.getBody().contains("Failed to retrieve"));

// Now drop the issue key
issueKey = issue1.getId().replace("TEST-", "");
pr.setTitle(issueKey + ": This is a pull request");

// The body should now contain the updated issue title
TestBotRunner.runPeriodicItems(checkBot);
assertTrue(pr.getBody().contains("My first issue"));
assertFalse(pr.getBody().contains("My second issue"));

// Now enter an invalid issue id
pr.setTitle("2384848: This is a pull request");

@@ -57,6 +57,9 @@ public Issue createIssue(String title, List<String> body) {

@Override
public Optional<Issue> getIssue(String id) {
if (id.indexOf('-') < 0) {
id = projectName.toUpperCase() + "-" + id;
}
var issue = request.get("issue/" + id)
.onError(r -> r.statusCode() == 404 ? JSON.object().put("NOT_FOUND", true) : null)
.execute();
@@ -161,7 +161,7 @@ TestPullRequest getPullRequest(TestHostedRepository repository, String id) {
}

TestIssue createIssue(TestIssueProject issueProject, String title, List<String> body) {
var id = String.valueOf(data.issues.size() + 1);
var id = issueProject.projectName().toUpperCase() + "-" + (data.issues.size() + 1);
var issue = TestIssue.createNew(issueProject, id, title, body);
data.issues.put(id ,issue);
return issue;
@@ -32,6 +32,10 @@
private final String projectName;
private final TestHost host;

String projectName() {
return projectName;
}

@Override
public Host host() {
return host;
@@ -54,6 +58,10 @@ public Issue createIssue(String title, List<String> body) {

@Override
public Optional<Issue> getIssue(String id) {
if (id.indexOf('-') < 0) {
id = projectName.toUpperCase() + "-" + id;
}

return Optional.ofNullable(host.getIssue(this, id));
}

0 comments on commit c8b859f

Please sign in to comment.
You can’t perform that action at this time.