-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* adding ctor with optional comments indices args * removing throws IOException declaration above new ctor * making reads and writes optional * quick comment change * adding test for new ctor --------- (cherry picked from commit bc215fd) Signed-off-by: Dennis Toepker <toepkerd@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Dennis Toepker <toepkerd@amazon.com>
- Loading branch information
1 parent
923e487
commit 5a73696
Showing
2 changed files
with
62 additions
and
7 deletions.
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
36 changes: 36 additions & 0 deletions
36
src/test/kotlin/org/opensearch/commons/alerting/model/DataSourcesTests.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,36 @@ | ||
package org.opensearch.commons.alerting.model | ||
|
||
import org.junit.jupiter.api.Assertions | ||
import org.junit.jupiter.api.Test | ||
import org.opensearch.common.io.stream.BytesStreamOutput | ||
import org.opensearch.core.common.io.stream.StreamInput | ||
|
||
class DataSourcesTests { | ||
@Test | ||
fun `Test DataSources construction with no comments indices`() { | ||
val dataSources = DataSources( | ||
ScheduledJob.DOC_LEVEL_QUERIES_INDEX, | ||
".opensearch-alerting-finding-history-write", | ||
"<.opensearch-alerting-finding-history-{now/d}-1>", | ||
".opendistro-alerting-alerts", | ||
".opendistro-alerting-alert-history-write", | ||
"<.opendistro-alerting-alert-history-{now/d}-1>", | ||
mapOf(), | ||
false | ||
) | ||
Assertions.assertNotNull(dataSources) | ||
|
||
val out = BytesStreamOutput() | ||
dataSources.writeTo(out) | ||
val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes) | ||
val newDataSources = DataSources(sin) | ||
Assertions.assertEquals(ScheduledJob.DOC_LEVEL_QUERIES_INDEX, newDataSources.queryIndex) | ||
Assertions.assertEquals(".opensearch-alerting-finding-history-write", newDataSources.findingsIndex) | ||
Assertions.assertEquals("<.opensearch-alerting-finding-history-{now/d}-1>", newDataSources.findingsIndexPattern) | ||
Assertions.assertEquals(".opendistro-alerting-alerts", newDataSources.alertsIndex) | ||
Assertions.assertEquals(".opendistro-alerting-alert-history-write", newDataSources.alertsHistoryIndex) | ||
Assertions.assertEquals("<.opendistro-alerting-alert-history-{now/d}-1>", newDataSources.alertsHistoryIndexPattern) | ||
Assertions.assertEquals(mapOf<String, Map<String, String>>(), newDataSources.queryIndexMappingsByType) | ||
Assertions.assertEquals(false, newDataSources.findingsEnabled) | ||
} | ||
} |