Skip to content

Commit

Permalink
RD-15242: DAS doesn't pick the parent epic key (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
bgaidioz authored Dec 18, 2024
1 parent 4baeae9 commit 8530102
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ private static String getIssueJqlKey(String columnName) {
return columnName.split("_")[0].toLowerCase();
}

private static final Map<String, String> jqlKeyMap = Map.of("status_category", "statusCategory");
private static final Map<String, String> jqlKeyMap =
Map.of("status_category", "statusCategory", "epic_key", "parentEpic");

public static String buildJqlQuery(List<Qual> quals) {
StringBuilder jqlQuery = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,21 +128,24 @@ private Row toRow(IssueBean issueBean, Map<String, String> names, List<String> c
statusCategory.map(s -> s.get("name")).orElse(null),
columns);

// Epic key is (possibly) found as parent->key, but we'd report it
// as epic_key only if the parent issue type is "Epic". Which is found
// in parent->fields->name = "Epic"
var epic =
maybeFields
.map(f -> f.get(names.get("Parent")))
.map(p -> (Map<String, Object>) p)
.map(p -> p.get("fields"))
.map(f -> (Map<String, Object>) f)
.map(f -> f.get(names.get("Issue Type")))
.map(i -> (Map<String, Object>) i)
.map(i -> i.get("name"))
.map(
name -> {
if (name.equals("Epic")) {
return maybeFields.get().get("key");
}
return null;
.map(fields -> (Map<String, Object>) fields.get(names.get("Parent")))
.flatMap(
parent -> {
return Optional.of((Map<String, Object>) parent.get("fields"))
.map(f -> (Map<String, Object>) f.get(names.get("Issue Type")))
.map(i -> i.get("name"))
.map(
name -> {
if (name.equals("Epic")) {
return (String) parent.get("key");
}
return null;
});
});

addToRow("epic_key", rowBuilder, epic.orElse(null), columns);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ void testGetIssues() throws IOException {
assertEquals("SP-1", extractValueFactory.extractValue(row, "key"));
assertEquals("Task", extractValueFactory.extractValue(row, "type"));
assertEquals("test issue", extractValueFactory.extractValue(row, "summary"));
assertEquals("RD-15048", extractValueFactory.extractValue(row, "epic_key"));
ObjectNode description = (ObjectNode) extractValueFactory.extractValue(row, "description");
// Fetch the first text of the content ("do this")
assertEquals(
Expand Down
62 changes: 60 additions & 2 deletions das-jira-connector/src/test/resources/mock-data/issues.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,43 @@
"self": "https://raw-labs.atlassian.net/rest/api/3/issue/33060",
"key": "SP-1",
"fields": {
"parent": {
"id": "33109",
"key": "RD-15048",
"self": "https://raw-labs.atlassian.net/rest/api/2/issue/33109",
"fields": {
"summary": "New onboarding - (UI, Repose, GitHub repos, Monitoring) ",
"status": {
"self": "https://raw-labs.atlassian.net/rest/api/2/status/3",
"description": "This issue is being actively worked on at the moment by the assignee.",
"iconUrl": "https://raw-labs.atlassian.net/images/icons/statuses/inprogress.png",
"name": "In Progress",
"id": "3",
"statusCategory": {
"self": "https://raw-labs.atlassian.net/rest/api/2/statuscategory/4",
"id": 4,
"key": "indeterminate",
"colorName": "yellow",
"name": "In Progress"
}
},
"priority": {
"self": "https://raw-labs.atlassian.net/rest/api/2/priority/3",
"iconUrl": "https://raw-labs.atlassian.net/images/icons/priorities/medium.svg",
"name": "Medium",
"id": "3"
},
"issuetype": {
"self": "https://raw-labs.atlassian.net/rest/api/2/issuetype/10000",
"id": "10000",
"description": "A big user story that needs to be broken down. Created by JIRA Software - do not edit or delete.",
"iconUrl": "https://raw-labs.atlassian.net/images/icons/issuetypes/epic.svg",
"name": "Epic",
"subtask": false,
"hierarchyLevel": 1
}
}
},
"statuscategorychangedate": "2024-10-18T13:53:06.820+0200",
"issuetype": {
"self": "https://raw-labs.atlassian.net/rest/api/3/issuetype/10117",
Expand Down Expand Up @@ -115,9 +152,29 @@
"name": "To Do"
}
},
"components": [{"self":"https://raw-labs.atlassian.net/rest/api/3/component/10151", "id":"10151", "name":"aComponent"}],
"components": [
{
"self": "https://raw-labs.atlassian.net/rest/api/3/component/10151",
"id": "10151",
"name": "aComponent"
}
],
"timeoriginalestimate": null,
"description": {"type":"doc","version":1.0,"content":[{"type":"paragraph","content":[{"type":"text","text":"do this"}]}]},
"description": {
"type": "doc",
"version": 1.0,
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "do this"
}
]
}
]
},
"customfield_10653": null,
"customfield_10600": null,
"security": null,
Expand Down Expand Up @@ -214,6 +271,7 @@
}
],
"names": {
"parent": "Parent",
"statuscategorychangedate": "Status Category Changed",
"issuetype": "Issue Type",
"timespent": "Time Spent",
Expand Down

0 comments on commit 8530102

Please sign in to comment.