From 7f65f40d76a18aea0dd7deb13bda592d77eaf315 Mon Sep 17 00:00:00 2001 From: Todd Young Date: Wed, 8 Jan 2025 11:36:05 -0500 Subject: [PATCH] feat: update the creation of new test assertions to use new regex OCD-4785 --- .../DatadogSyntheticsTestService.java | 2 +- .../FixDatadogUrlUptimeAssertionsJob.java | 26 +++++-------------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/chpl/chpl-service/src/main/java/gov/healthit/chpl/scheduler/job/urluptime/DatadogSyntheticsTestService.java b/chpl/chpl-service/src/main/java/gov/healthit/chpl/scheduler/job/urluptime/DatadogSyntheticsTestService.java index ca5535ea31..90ed216ca8 100644 --- a/chpl/chpl-service/src/main/java/gov/healthit/chpl/scheduler/job/urluptime/DatadogSyntheticsTestService.java +++ b/chpl/chpl-service/src/main/java/gov/healthit/chpl/scheduler/job/urluptime/DatadogSyntheticsTestService.java @@ -110,7 +110,7 @@ public SyntheticsAPITest createSyntheticsTest(String url, List developerId .type(SyntheticsAssertionType.STATUS_CODE)), new SyntheticsAssertion(new SyntheticsAssertionTarget() .operator(SyntheticsAssertionOperator.MATCHES) - .target("/[\\S\s]+[\\S]+/") + .target("/[\\S]/") .type(SyntheticsAssertionType.BODY)))) .request(new SyntheticsTestRequest() .url(url) diff --git a/chpl/chpl-service/src/main/java/gov/healthit/chpl/scheduler/job/urluptime/FixDatadogUrlUptimeAssertionsJob.java b/chpl/chpl-service/src/main/java/gov/healthit/chpl/scheduler/job/urluptime/FixDatadogUrlUptimeAssertionsJob.java index d42d532625..6e302af77c 100644 --- a/chpl/chpl-service/src/main/java/gov/healthit/chpl/scheduler/job/urluptime/FixDatadogUrlUptimeAssertionsJob.java +++ b/chpl/chpl-service/src/main/java/gov/healthit/chpl/scheduler/job/urluptime/FixDatadogUrlUptimeAssertionsJob.java @@ -2,8 +2,6 @@ import java.util.Arrays; import java.util.Collections; -import java.util.List; -import java.util.Optional; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; @@ -63,8 +61,7 @@ public void execute(JobExecutionContext context) throws JobExecutionException { datadogSyntheticsTestService.getAllSyntheticsTests().forEach(test -> { String url = test.getConfig().getRequest().getUrl(); - if (url.equals("https://www.praxisemr.com/applicationaccess/api/help/")) { - SyntheticsAPITest body = new SyntheticsAPITest() + SyntheticsAPITest body = new SyntheticsAPITest() .config(new SyntheticsAPITestConfig() .assertions(Arrays.asList( new SyntheticsAssertion(new SyntheticsAssertionTarget() @@ -115,28 +112,17 @@ public void execute(JobExecutionContext context) throws JobExecutionException { .name(url) .tags(test.getTags()); - try { - datadogSyntheticsTestService.getApiProvider().getApiInstance().updateAPITest(test.getPublicId(), body); - LOGGER.info("Test updated: {}", url); - } catch (ApiException e) { - LOGGER.error("Could not update test for URL: {}", url, e); - } - } else { - LOGGER.info("Test NOT updated: {}", url); + try { + datadogSyntheticsTestService.getApiProvider().getApiInstance().updateAPITest(test.getPublicId(), body); + LOGGER.info("Test updated: {}", url); + } catch (ApiException e) { + LOGGER.error("Could not update test for URL: {}", url, e); } }); LOGGER.info("********* Completed the Fix Datadog Url Uptime Assertions Job *********"); } - private Optional getContentHeaderAssertionExist(List assertions) { - return assertions.stream() - .filter(assertion -> assertion.getSyntheticsAssertionTarget().getType().equals(SyntheticsAssertionType.HEADER) - && assertion.getSyntheticsAssertionTarget().getProperty().equals("content-length")) - .findAny(); - - } - private Long convertMinutesToSeconds(Long minutes) { return minutes * SECONDS_IN_A_MINUTE; }