Skip to content

Commit e2d4d7c

Browse files
authored
Add Seconds as a supported unit for IntervalSchedule (#849)
* Add Seconds as a supported unit for IntervalSchedule Signed-off-by: Craig Perkins <[email protected]> * Fix test Signed-off-by: Craig Perkins <[email protected]> * Added a comment Signed-off-by: Craig Perkins <[email protected]> --------- Signed-off-by: Craig Perkins <[email protected]>
1 parent d257620 commit e2d4d7c

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/main/kotlin/org/opensearch/commons/alerting/model/Schedule.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,9 @@ data class IntervalSchedule(
282282
sin.readEnum(ChronoUnit::class.java) // unit
283283
)
284284
companion object {
285+
// Including SECONDS in this list for testing purposes to run test monitors in order of seconds
285286
@Transient
286-
private val SUPPORTED_UNIT = listOf(ChronoUnit.MINUTES, ChronoUnit.HOURS, ChronoUnit.DAYS)
287+
private val SUPPORTED_UNIT = listOf(ChronoUnit.SECONDS, ChronoUnit.MINUTES, ChronoUnit.HOURS, ChronoUnit.DAYS)
287288

288289
@JvmStatic
289290
@Throws(IOException::class)

src/test/kotlin/org/opensearch/commons/alerting/model/ScheduleTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ class ScheduleTest : XContentTestBase {
339339
@Test
340340
fun `test invalid interval units`() {
341341
assertFailsWith(IllegalArgumentException::class, "Expected IllegalArgumentException") {
342-
IntervalSchedule(1, ChronoUnit.SECONDS)
342+
IntervalSchedule(1, ChronoUnit.YEARS)
343343
}
344344

345345
assertFailsWith(IllegalArgumentException::class, "Expected IllegalArgumentException") {

0 commit comments

Comments
 (0)