forked from opensearch-project/common-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add condition to the templateArg of BucketLevelTrigger (opensearch-pr…
…oject#576) * Add condition to templateArg of BucketLevelTrigger Signed-off-by: Chase Engelbrecht <[email protected]> * Remove debug println Signed-off-by: Chase Engelbrecht <[email protected]> --------- Signed-off-by: Chase Engelbrecht <[email protected]>
- Loading branch information
Showing
2 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/test/kotlin/org/opensearch/commons/alerting/model/BucketLevelTriggerTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.opensearch.commons.alerting.model | ||
|
||
import org.junit.jupiter.api.Test | ||
import org.opensearch.commons.alerting.randomBucketLevelTrigger | ||
import kotlin.test.assertEquals | ||
|
||
class BucketLevelTriggerTests { | ||
|
||
@Test | ||
fun `test asTemplateArgs returns expected values`() { | ||
val bucketLevelTrigger = randomBucketLevelTrigger() | ||
val templateArg = bucketLevelTrigger.asTemplateArg() | ||
|
||
assertEquals(templateArg[Trigger.ID_FIELD], bucketLevelTrigger.id) | ||
assertEquals(templateArg[Trigger.NAME_FIELD], bucketLevelTrigger.name) | ||
assertEquals(templateArg[Trigger.SEVERITY_FIELD], bucketLevelTrigger.severity) | ||
assertEquals(templateArg[Trigger.ACTIONS_FIELD], bucketLevelTrigger.actions.map { it.asTemplateArg() }) | ||
assertEquals(templateArg[BucketLevelTrigger.PARENT_BUCKET_PATH], bucketLevelTrigger.bucketSelector.parentBucketPath) | ||
assertEquals(templateArg[BucketLevelTrigger.CONDITION_FIELD], bucketLevelTrigger.bucketSelector.script.idOrCode) | ||
} | ||
} |