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.
adding ctor with optional comments indices args (opensearch-project#674)
* adding ctor with optional comments indices args Signed-off-by: Dennis Toepker <[email protected]> * removing throws IOException declaration above new ctor Signed-off-by: Dennis Toepker <[email protected]> * making reads and writes optional Signed-off-by: Dennis Toepker <[email protected]> * quick comment change Signed-off-by: Dennis Toepker <[email protected]> * adding test for new ctor Signed-off-by: Dennis Toepker <[email protected]> --------- Signed-off-by: Dennis Toepker <[email protected]> Co-authored-by: Dennis Toepker <[email protected]>
- Loading branch information
1 parent
480590d
commit bc215fd
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) | ||
} | ||
} |