From 7ffe725739063d5bc3f412a3c29f76d8f1429d37 Mon Sep 17 00:00:00 2001 From: Jessica Rodriguez Date: Tue, 7 Jan 2025 13:21:11 -0500 Subject: [PATCH] Remove environment_url, db migration --- .../pagerduty/PagerDutyTransformer.java | 41 ------------------- .../pagerduty/PagerDutyTestUtils.java | 37 ----------------- .../pagerduty/PagerDutyTransformerTest.java | 37 ----------------- ...UD-22813_update_template_host_app_urls.sql | 11 +++++ .../processors/camel/CamelProcessor.java | 5 --- .../pagerduty/PagerDutyProcessor.java | 5 --- .../processors/camel/CamelProcessorTest.java | 3 +- .../google/chat/GoogleChatProcessorTest.java | 14 +++---- .../camel/slack/SlackProcessorTest.java | 12 +++--- .../camel/teams/TeamsProcessorTest.java | 16 ++++---- .../pagerduty/PagerDutyProcessorTest.java | 5 --- 11 files changed, 34 insertions(+), 152 deletions(-) create mode 100644 database/src/main/resources/db/migration/V1.110.0__RHCLOUD-22813_update_template_host_app_urls.sql diff --git a/connector-pagerduty/src/main/java/com/redhat/cloud/notifications/connector/pagerduty/PagerDutyTransformer.java b/connector-pagerduty/src/main/java/com/redhat/cloud/notifications/connector/pagerduty/PagerDutyTransformer.java index b12da65f12..9bc3f3c445 100644 --- a/connector-pagerduty/src/main/java/com/redhat/cloud/notifications/connector/pagerduty/PagerDutyTransformer.java +++ b/connector-pagerduty/src/main/java/com/redhat/cloud/notifications/connector/pagerduty/PagerDutyTransformer.java @@ -32,7 +32,6 @@ public class PagerDutyTransformer implements Processor { public static final String CONTEXT = "context"; public static final String CUSTOM_DETAILS = "custom_details"; public static final String DISPLAY_NAME = "display_name"; - public static final String ENVIRONMENT_URL = "environment_url"; public static final String EVENT_ACTION = "event_action"; public static final String EVENT_TYPE = "event_type"; public static final String EVENTS = "events"; @@ -57,7 +56,6 @@ public void process(Exchange exchange) { JsonObject message = new JsonObject(); message.put(EVENT_ACTION, PagerDutyEventAction.TRIGGER); - message.mergeIn(getClientLink(cloudEventPayload, cloudEventPayload.getString(ENVIRONMENT_URL))); message.mergeIn(getClientLinks(cloudEventPayload)); JsonObject messagePayload = new JsonObject(); @@ -124,45 +122,6 @@ private void validatePayload(final JsonObject cloudEventPayload) { } } - /** - * Adapted from CamelProcessor template for Teams, with some changes to more gracefully handle missing fields - *
- * TODO update to work more consistently and with other platforms - * - * @return {@link #CLIENT} and {@link #CLIENT_URL} - */ - private JsonObject getClientLink(final JsonObject cloudEventPayload, String environmentUrl) { - JsonObject clientLink = new JsonObject(); - - String contextName = cloudEventPayload.containsKey(CONTEXT) - ? cloudEventPayload.getJsonObject(CONTEXT).getString(DISPLAY_NAME) - : null; - - if (contextName != null) { - clientLink.put(CLIENT, contextName); - - String inventoryId = cloudEventPayload.getJsonObject(CONTEXT).getString("inventory_id"); - if (environmentUrl != null && !environmentUrl.isEmpty() && inventoryId != null && !inventoryId.isEmpty()) { - clientLink.put(CLIENT_URL, String.format("%s/insights/inventory/%s", - environmentUrl, - cloudEventPayload.getJsonObject(CONTEXT).getString("inventory_id") - )); - } - } else { - if (environmentUrl != null && !environmentUrl.isEmpty()) { - clientLink.put(CLIENT, String.format("Open %s", cloudEventPayload.getString(APPLICATION))); - clientLink.put(CLIENT_URL, String.format("%s/insights/%s", - environmentUrl, - cloudEventPayload.getString(APPLICATION) - )); - } else { - clientLink.put(CLIENT, cloudEventPayload.getString(APPLICATION)); - } - } - - return clientLink; - } - /** * Performs the following link conversions: *