Skip to content
Permalink
Browse files

JENKINS-49178 Refactor variable names.

  • Loading branch information
ceilfors committed Apr 21, 2018
1 parent a6874e3 commit e3eb73b12a0aa1c7a90562beadfed881dcbb2faa
@@ -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)
)
}
@@ -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'))
)
}
}
@@ -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', '')
}

0 comments on commit e3eb73b

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