-
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.
adds tests for workflow request and response objects
Signed-off-by: Surya Sashank Nistala <snistala@amazon.com>
- Loading branch information
Showing
8 changed files
with
119 additions
and
1 deletion.
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
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
2 changes: 1 addition & 1 deletion
2
src/test/kotlin/org/opensearch/commons/alerting/action/DeleteWorkflowRequestTests.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
25 changes: 25 additions & 0 deletions
25
src/test/kotlin/org/opensearch/commons/alerting/action/DeleteWorkflowResponseTests.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,25 @@ | ||
package org.opensearch.commons.alerting.action | ||
|
||
import org.junit.Assert | ||
import org.junit.jupiter.api.Test | ||
import org.opensearch.common.io.stream.BytesStreamOutput | ||
import org.opensearch.common.io.stream.StreamInput | ||
|
||
class DeleteWorkflowResponseTests { | ||
|
||
@Test | ||
fun `test delete workflow response`() { | ||
|
||
val res = DeleteWorkflowResponse(id = "w1", version = 1, nonDeletedMonitors = listOf("m1")) | ||
Assert.assertNotNull(res) | ||
Assert.assertEquals("w1", res.id) | ||
|
||
val out = BytesStreamOutput() | ||
res.writeTo(out) | ||
val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes) | ||
val newRes = DeleteWorkflowResponse(sin) | ||
Assert.assertEquals("w1", newRes.id) | ||
Assert.assertEquals("m1", newRes.nonDeletedMonitors!!.get(0)) | ||
Assert.assertEquals(1, newRes.version) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/test/kotlin/org/opensearch/commons/alerting/action/GetWorkflowRequestTests.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,23 @@ | ||
package org.opensearch.commons.alerting.action | ||
|
||
import org.junit.jupiter.api.Assertions | ||
import org.junit.jupiter.api.Test | ||
import org.opensearch.common.io.stream.BytesStreamOutput | ||
import org.opensearch.common.io.stream.StreamInput | ||
import org.opensearch.rest.RestRequest | ||
|
||
class GetWorkflowRequestTests { | ||
|
||
@Test | ||
fun testGetWorkflowRequest() { | ||
val request = GetWorkflowRequest("w1", RestRequest.Method.GET) | ||
Assertions.assertNull(request.validate()) | ||
|
||
val out = BytesStreamOutput() | ||
request.writeTo(out) | ||
val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes) | ||
val newReq = GetWorkflowRequest(sin) | ||
Assertions.assertEquals("w1", newReq.workflowId) | ||
Assertions.assertEquals(RestRequest.Method.GET, newReq.method) | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/test/kotlin/org/opensearch/commons/alerting/action/GetWorkflowResponseTests.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,26 @@ | ||
package org.opensearch.commons.alerting.action | ||
|
||
import org.junit.jupiter.api.Assertions | ||
import org.junit.jupiter.api.Test | ||
import org.opensearch.common.io.stream.BytesStreamOutput | ||
import org.opensearch.common.io.stream.StreamInput | ||
import org.opensearch.commons.alerting.randomWorkflow | ||
import org.opensearch.rest.RestStatus | ||
|
||
class GetWorkflowResponseTests { | ||
|
||
@Test | ||
fun testGetWorkflowRequest() { | ||
val workflow = randomWorkflow() | ||
val response = GetWorkflowResponse( | ||
id = "id", version = 1, seqNo = 1, primaryTerm = 1, status = RestStatus.OK, workflow = workflow | ||
) | ||
val out = BytesStreamOutput() | ||
response.writeTo(out) | ||
val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes) | ||
val newRes = GetWorkflowResponse(sin) | ||
Assertions.assertEquals("id", newRes.id) | ||
Assertions.assertEquals(workflow.name, newRes.workflow!!.name) | ||
Assertions.assertEquals(workflow.owner, newRes.workflow!!.owner) | ||
} | ||
} |
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
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