From 1cb8cd9ba042b7b466bd376095f507c8e0645a23 Mon Sep 17 00:00:00 2001 From: vikhy-aws <191836418+vikhy-aws@users.noreply.github.com> Date: Fri, 31 Jan 2025 17:41:09 -0800 Subject: [PATCH] fix: fix nitpicks Signed-off-by: vikhy-aws <191836418+vikhy-aws@users.noreply.github.com> --- .../resthandler/RestIndexMonitorAction.kt | 28 +++++++++---------- .../alerting/resthandler/MonitorRestApiIT.kt | 18 ++++++------ 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/resthandler/RestIndexMonitorAction.kt b/alerting/src/main/kotlin/org/opensearch/alerting/resthandler/RestIndexMonitorAction.kt index 1134c43c3..0562eca13 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/resthandler/RestIndexMonitorAction.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/resthandler/RestIndexMonitorAction.kt @@ -92,7 +92,7 @@ class RestIndexMonitorAction : BaseRestHandler() { if (request.method() == PUT && !isValidId(id)) { throw IllegalArgumentException( "Invalid monitor ID [$id]. " + - "Monitor ID should be alphanumeric string with +, /, _, or - characters only" + "Monitor ID should be alphanumeric string with +, /, _, or - characters only." ) } @@ -109,7 +109,7 @@ class RestIndexMonitorAction : BaseRestHandler() { if (!isValidName(monitor.name)) { throw IllegalArgumentException( "Invalid monitor name [${monitor.name}]. " + - "Monitor Name should be alphanumeric (4-50 chars) starting with letter or underscore" + "Monitor Name should be alphanumeric (4-50 chars) starting with letter or underscore." ) } @@ -124,12 +124,12 @@ class RestIndexMonitorAction : BaseRestHandler() { Monitor.MonitorType.QUERY_LEVEL_MONITOR -> { triggers.forEach { if (it !is QueryLevelTrigger) { - throw (IllegalArgumentException("Illegal trigger type, ${it.javaClass.name}, for query level monitor")) + throw (IllegalArgumentException("Illegal trigger type, ${it.javaClass.name}, for query level monitor.")) } if (!isValidName(it.name)) { throw IllegalArgumentException( "Invalid trigger name [${it.name}]. " + - "Trigger Name should be alphanumeric (4-50 chars) starting with letter or underscore" + "Trigger Name should be alphanumeric (4-50 chars) starting with letter or underscore." ) } it.actions.forEach { action -> @@ -137,7 +137,7 @@ class RestIndexMonitorAction : BaseRestHandler() { if (!isValidId(destinationId)) { throw IllegalArgumentException( "Invalid destination ID [$destinationId]. " + - "Destination ID should be alphanumeric string with +, /, _, or - characters only" + "Destination ID should be alphanumeric string with +, /, _, or - characters only." ) } } @@ -147,12 +147,12 @@ class RestIndexMonitorAction : BaseRestHandler() { Monitor.MonitorType.BUCKET_LEVEL_MONITOR -> { triggers.forEach { if (it !is BucketLevelTrigger) { - throw IllegalArgumentException("Illegal trigger type, ${it.javaClass.name}, for bucket level monitor") + throw IllegalArgumentException("Illegal trigger type, ${it.javaClass.name}, for bucket level monitor.") } if (!isValidName(it.name)) { throw IllegalArgumentException( "Invalid trigger name [${it.name}]. " + - "Trigger Name should be alphanumeric (4-50 chars) starting with letter or underscore" + "Trigger Name should be alphanumeric (4-50 chars) starting with letter or underscore." ) } it.actions.forEach { action -> @@ -160,7 +160,7 @@ class RestIndexMonitorAction : BaseRestHandler() { if (!isValidId(destinationId)) { throw IllegalArgumentException( "Invalid destination ID [$destinationId]. " + - "Destination ID should be alphanumeric string with +, /, _, or - characters only" + "Destination ID should be alphanumeric string with +, /, _, or - characters only." ) } } @@ -170,12 +170,12 @@ class RestIndexMonitorAction : BaseRestHandler() { Monitor.MonitorType.CLUSTER_METRICS_MONITOR -> { triggers.forEach { if (it !is QueryLevelTrigger) { - throw IllegalArgumentException("Illegal trigger type, ${it.javaClass.name}, for cluster metrics monitor") + throw IllegalArgumentException("Illegal trigger type, ${it.javaClass.name}, for cluster metrics monitor.") } if (!isValidName(it.name)) { throw IllegalArgumentException( "Invalid trigger name [${it.name}]. " + - "Trigger Name should be alphanumeric (4-50 chars) starting with letter or underscore" + "Trigger Name should be alphanumeric (4-50 chars) starting with letter or underscore." ) } it.actions.forEach { action -> @@ -183,7 +183,7 @@ class RestIndexMonitorAction : BaseRestHandler() { if (!isValidId(destinationId)) { throw IllegalArgumentException( "Invalid destination ID [$destinationId]. " + - "Destination ID should be alphanumeric string with +, /, _, or - characters only" + "Destination ID should be alphanumeric string with +, /, _, or - characters only." ) } } @@ -194,12 +194,12 @@ class RestIndexMonitorAction : BaseRestHandler() { validateDocLevelQueryName(monitor) triggers.forEach { if (it !is DocumentLevelTrigger) { - throw IllegalArgumentException("Illegal trigger type, ${it.javaClass.name}, for document level monitor") + throw IllegalArgumentException("Illegal trigger type, ${it.javaClass.name}, for document level monitor.") } if (!isValidName(it.name)) { throw IllegalArgumentException( "Invalid trigger name [${it.name}]. " + - "Trigger Name should be alphanumeric (4-50 chars) starting with letter or underscore" + "Trigger Name should be alphanumeric (4-50 chars) starting with letter or underscore." ) } it.actions.forEach { action -> @@ -207,7 +207,7 @@ class RestIndexMonitorAction : BaseRestHandler() { if (!isValidId(destinationId)) { throw IllegalArgumentException( "Invalid destination ID [$destinationId]. " + - "Destination ID should be alphanumeric string with +, /, _, or - characters only" + "Destination ID should be alphanumeric string with +, /, _, or - characters only." ) } } diff --git a/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/MonitorRestApiIT.kt b/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/MonitorRestApiIT.kt index 05ec6b556..62b067584 100644 --- a/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/MonitorRestApiIT.kt +++ b/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/MonitorRestApiIT.kt @@ -273,17 +273,17 @@ class MonitorRestApiIT : AlertingRestTestCase() { val expectedError = mapOf( "error" to mapOf( "reason" to "Invalid monitor name [$invalidName]. " + - "Monitor Name should be alphanumeric (4-50 chars) starting with letter or underscore", + "Monitor Name should be alphanumeric (4-50 chars) starting with letter or underscore.", "caused_by" to mapOf( "reason" to "java.lang.IllegalArgumentException: Invalid monitor name [$invalidName]. " + - "Monitor Name should be alphanumeric (4-50 chars) starting with letter or underscore", + "Monitor Name should be alphanumeric (4-50 chars) starting with letter or underscore.", "type" to "exception" ), "type" to "alerting_exception", "root_cause" to listOf( mapOf( "reason" to "Invalid monitor name [$invalidName]. " + - "Monitor Name should be alphanumeric (4-50 chars) starting with letter or underscore", + "Monitor Name should be alphanumeric (4-50 chars) starting with letter or underscore.", "type" to "alerting_exception", ) ) @@ -304,17 +304,17 @@ class MonitorRestApiIT : AlertingRestTestCase() { val expectedError = mapOf( "error" to mapOf( "reason" to "Invalid trigger name [$invalidName]. " + - "Trigger Name should be alphanumeric (4-50 chars) starting with letter or underscore", + "Trigger Name should be alphanumeric (4-50 chars) starting with letter or underscore.", "caused_by" to mapOf( "reason" to "java.lang.IllegalArgumentException: Invalid trigger name [$invalidName]. " + - "Trigger Name should be alphanumeric (4-50 chars) starting with letter or underscore", + "Trigger Name should be alphanumeric (4-50 chars) starting with letter or underscore.", "type" to "exception" ), "type" to "alerting_exception", "root_cause" to listOf( mapOf( "reason" to "Invalid trigger name [$invalidName]. " + - "Trigger Name should be alphanumeric (4-50 chars) starting with letter or underscore", + "Trigger Name should be alphanumeric (4-50 chars) starting with letter or underscore.", "type" to "alerting_exception", ) ) @@ -335,17 +335,17 @@ class MonitorRestApiIT : AlertingRestTestCase() { val expectedError = mapOf( "error" to mapOf( "reason" to "Invalid destination ID [$invalidId]. " + - "Destination ID should be alphanumeric string with +, /, _, or - characters only", + "Destination ID should be alphanumeric string with +, /, _, or - characters only.", "caused_by" to mapOf( "reason" to "java.lang.IllegalArgumentException: Invalid destination ID [$invalidId]. " + - "Destination ID should be alphanumeric string with +, /, _, or - characters only", + "Destination ID should be alphanumeric string with +, /, _, or - characters only.", "type" to "exception" ), "type" to "alerting_exception", "root_cause" to listOf( mapOf( "reason" to "Invalid destination ID [$invalidId]. " + - "Destination ID should be alphanumeric string with +, /, _, or - characters only", + "Destination ID should be alphanumeric string with +, /, _, or - characters only.", "type" to "alerting_exception", ) )