Skip to content

Commit

Permalink
add fields param in toxcontent() for doc level query (#549)
Browse files Browse the repository at this point in the history
Signed-off-by: Surya Sashank Nistala <snistala@amazon.com>
(cherry picked from commit f290fec)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Oct 24, 2023
1 parent 38cd12b commit 4af09ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ data class DocLevelQuery(
builder.startObject()
.field(QUERY_ID_FIELD, id)
.field(NAME_FIELD, name)
.field(FIELDS_FIELD, fields.toTypedArray())
.field(QUERY_FIELD, query)
.field(TAGS_FIELD, tags.toTypedArray())
.endObject()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,18 @@ class XContentTests {
)
}

@Test
fun `test doc level query toXcontent`() {
val dlq = DocLevelQuery("id", "name", listOf("f1", "f2"), "query", listOf("t1", "t2"))
val dlqString = dlq.toXContent(builder(), ToXContent.EMPTY_PARAMS).string()
val parsedDlq = DocLevelQuery.parse(parser(dlqString))
Assertions.assertEquals(
dlq,
parsedDlq,
"Round tripping Doc level query doesn't work"
)
}

@Test
fun `test alert parsing`() {
val alert = randomAlert()
Expand Down

0 comments on commit 4af09ee

Please sign in to comment.