Skip to content

Commit

Permalink
JENKINS-49178 Refactor variable names.
Browse files Browse the repository at this point in the history
  • Loading branch information
ceilfors committed Apr 21, 2018
1 parent a6874e3 commit e3eb73b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
Expand Up @@ -24,15 +24,15 @@ class WebhookChangelogEventJsonParser implements JsonObjectParser<WebhookChangel
private final IssueJsonParser issueJsonParser = new IssueJsonParser(new JSONObject([:]), new JSONObject([:]))

@Override
WebhookChangelogEvent parse(JSONObject json) throws JSONException {
satisfyRequiredKeys(json)
WebhookChangelogEvent parse(JSONObject webhookEvent) throws JSONException {
satisfyRequiredKeys(webhookEvent)

Collection<ChangelogItem> items = JsonParseUtil.parseJsonArray(
json.getJSONObject('changelog').getJSONArray('items'), changelogItemJsonParser)
webhookEvent.getJSONObject('changelog').getJSONArray('items'), changelogItemJsonParser)
new WebhookChangelogEvent(
json.getLong('timestamp'),
json.getString('webhookEvent'),
issueJsonParser.parse(json.getJSONObject('issue')),
webhookEvent.getLong('timestamp'),
webhookEvent.getString('webhookEvent'),
issueJsonParser.parse(webhookEvent.getJSONObject('issue')),
new ChangelogGroup(null, null, items)
)
}
Expand Down
Expand Up @@ -22,22 +22,22 @@ class WebhookCommentEventJsonParser implements JsonObjectParser<WebhookCommentEv
/**
* Fills details needed by JRC JSON Parser that are missing in JIRA Cloud Webhook events.
*/
private static void satisfyCloudRequiredKeys(JSONObject json) {
JSONObject fields = json.getJSONObject(ISSUE_KEY).getJSONObject('fields')
private static void satisfyCloudRequiredKeys(JSONObject webhookEvent) {
JSONObject fields = webhookEvent.getJSONObject(ISSUE_KEY).getJSONObject('fields')
putIfAbsent(fields, 'created', DATE_FIELD_NOT_EXIST)
putIfAbsent(fields, 'updated', DATE_FIELD_NOT_EXIST)
}

@Override
WebhookCommentEvent parse(JSONObject json) throws JSONException {
satisfyRequiredKeys(json)
satisfyCloudRequiredKeys(json)
WebhookCommentEvent parse(JSONObject webhookEvent) throws JSONException {
satisfyRequiredKeys(webhookEvent)
satisfyCloudRequiredKeys(webhookEvent)

new WebhookCommentEvent(
json.getLong('timestamp'),
json.getString('webhookEvent'),
issueJsonParser.parse(json.getJSONObject(ISSUE_KEY)),
new CommentJsonParser().parse(json.getJSONObject('comment'))
webhookEvent.getLong('timestamp'),
webhookEvent.getString('webhookEvent'),
issueJsonParser.parse(webhookEvent.getJSONObject(ISSUE_KEY)),
new CommentJsonParser().parse(webhookEvent.getJSONObject('comment'))
)
}
}
Expand Up @@ -10,8 +10,8 @@ class WebhookJsonParserUtils {
/**
* Fills details needed by JRC JSON Parser that are missing in Webhook events.
*/
static void satisfyRequiredKeys(JSONObject json) {
JSONObject issue = json.getJSONObject('issue')
static void satisfyRequiredKeys(JSONObject webhookEvent) {
JSONObject issue = webhookEvent.getJSONObject('issue')
putIfAbsent(issue, 'expand', '')
}

Expand Down

0 comments on commit e3eb73b

Please sign in to comment.