Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
Signed-off-by: Dennis Toepker <[email protected]>
  • Loading branch information
toepkerd-zz committed Jun 10, 2024
1 parent b2ba4c6 commit 10123c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@ import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertNotNull
import org.junit.jupiter.api.Test
import org.opensearch.common.io.stream.BytesStreamOutput
import org.opensearch.commons.alerting.model.Comment
import org.opensearch.core.common.io.stream.StreamInput
import org.opensearch.rest.RestRequest

class IndexCommentRequestTests {
@Test
fun `test index comment post request`() {
val req = IndexCommentRequest("123", "alert", "456", 1L, 2L, RestRequest.Method.POST, "comment")
val req = IndexCommentRequest("123", Comment.EntityType.ALERT.value, "456", 1L, 2L, RestRequest.Method.POST, "comment")
assertNotNull(req)
val out = BytesStreamOutput()
req.writeTo(out)
val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes)
val newReq = IndexCommentRequest(sin)
assertEquals("123", newReq.entityId)
assertEquals(Comment.EntityType.ALERT.value, newReq.entityType)
assertEquals("456", newReq.commentId)
assertEquals(1L, newReq.seqNo)
assertEquals(2L, newReq.primaryTerm)
Expand All @@ -26,13 +28,14 @@ class IndexCommentRequestTests {

@Test
fun `test index comment put request`() {
val req = IndexCommentRequest("123", "alert", "456", 1L, 2L, RestRequest.Method.PUT, "comment")
val req = IndexCommentRequest("123", Comment.EntityType.ALERT.value, "456", 1L, 2L, RestRequest.Method.PUT, "comment")
assertNotNull(req)
val out = BytesStreamOutput()
req.writeTo(out)
val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes)
val newReq = IndexCommentRequest(sin)
assertEquals("123", newReq.entityId)
assertEquals(Comment.EntityType.ALERT.value, newReq.entityType)
assertEquals("456", newReq.commentId)
assertEquals(1L, newReq.seqNo)
assertEquals(2L, newReq.primaryTerm)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class IndexCommentResponseTests {
fun `test index comment response with comment`() {
val comment = Comment(
"123",
"alert",
Comment.EntityType.ALERT.value,
"456",
"comment",
Instant.now(),
Expand Down

0 comments on commit 10123c6

Please sign in to comment.