Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

119: Support fetching Jira issues with only a partial id #183

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions bots/pr/src/test/java/org/openjdk/skara/bots/pr/CheckTests.java
Expand Up @@ -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");

Expand Down
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion test/src/main/java/org/openjdk/skara/test/TestHost.java
Expand Up @@ -161,7 +161,7 @@ List<TestPullRequest> getPullRequests(TestHostedRepository repository) {
}

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;
Expand Down
Expand Up @@ -32,6 +32,10 @@ public class TestIssueProject implements IssueProject {
private final String projectName;
private final TestHost host;

String projectName() {
return projectName;
}

@Override
public Host host() {
return host;
Expand All @@ -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));
}

Expand Down