From cae9460bce81e6c61a244ec9169f1bdb82433001 Mon Sep 17 00:00:00 2001 From: Joshua Au Date: Wed, 11 Oct 2023 14:15:52 -0400 Subject: [PATCH] Fixed tests for ExplainRequest Signed-off-by: Joshua Au --- .../indexstatemanagement/model/ExplainFilter.kt | 12 ++++++------ .../transport/action/explain/ExplainRequestTests.kt | 7 +++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/model/ExplainFilter.kt b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/model/ExplainFilter.kt index 8fb09d7e7..ba562948f 100644 --- a/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/model/ExplainFilter.kt +++ b/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/model/ExplainFilter.kt @@ -27,16 +27,16 @@ data class ExplainFilter( @Throws(IOException::class) constructor(sin: StreamInput) : this( - filterPolicyID = sin.readString(), - filterState = sin.readString(), - filterAction = sin.readString() + filterPolicyID = sin.readOptionalString(), + filterState = sin.readOptionalString(), + filterAction = sin.readOptionalString() ) @Throws(IOException::class) override fun writeTo(out: StreamOutput) { - out.writeString(filterPolicyID) - out.writeString(filterState) - out.writeString(filterAction) + out.writeOptionalString(filterPolicyID) + out.writeOptionalString(filterState) + out.writeOptionalString(filterAction) } fun isValid(managedIndexConfig: ManagedIndexConfig): Boolean { diff --git a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/transport/action/explain/ExplainRequestTests.kt b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/transport/action/explain/ExplainRequestTests.kt index 0c8d0e01e..832322a1a 100644 --- a/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/transport/action/explain/ExplainRequestTests.kt +++ b/src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/transport/action/explain/ExplainRequestTests.kt @@ -9,6 +9,7 @@ import org.opensearch.common.io.stream.BytesStreamOutput import org.opensearch.core.common.io.stream.StreamInput import org.opensearch.common.unit.TimeValue import org.opensearch.indexmanagement.common.model.rest.SearchParams +import org.opensearch.indexmanagement.indexstatemanagement.model.ExplainFilter import org.opensearch.indexmanagement.indexstatemanagement.util.DEFAULT_INDEX_TYPE import org.opensearch.test.OpenSearchTestCase @@ -19,9 +20,10 @@ class ExplainRequestTests : OpenSearchTestCase() { val local = true val clusterManagerTimeout = TimeValue.timeValueSeconds(30) val params = SearchParams(0, 20, "sort-field", "asc", "*") + val filter = ExplainFilter() val showPolicy = false val showValidationResult = false - val req = ExplainRequest(indices, local, clusterManagerTimeout, params, showPolicy, showValidationResult, DEFAULT_INDEX_TYPE) + val req = ExplainRequest(indices, local, clusterManagerTimeout, params, filter, showPolicy, showValidationResult, DEFAULT_INDEX_TYPE) val out = BytesStreamOutput() req.writeTo(out) @@ -36,9 +38,10 @@ class ExplainRequestTests : OpenSearchTestCase() { val local = true val clusterManagerTimeout = TimeValue.timeValueSeconds(30) val params = SearchParams(0, 20, "sort-field", "asc", "*") + val filter = ExplainFilter() val showPolicy = false val showValidationResult = false - val req = ExplainRequest(indices, local, clusterManagerTimeout, params, showPolicy, showValidationResult, "non-existent-index-type") + val req = ExplainRequest(indices, local, clusterManagerTimeout, params, filter, showPolicy, showValidationResult, "non-existent-index-type") val actualException: String? = req.validate()?.validationErrors()?.firstOrNull() val expectedException: String = ExplainRequest.MULTIPLE_INDICES_CUSTOM_INDEX_TYPE_ERROR