From b62d6f64cde7725f6bba14ec1410d8208fa977fe Mon Sep 17 00:00:00 2001 From: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> Date: Thu, 24 Mar 2022 01:32:21 -0700 Subject: [PATCH] Remove allowedConfigFeatureList from GetPluginFeaturesResponse Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> --- .../notifications/NotificationConstants.kt | 1 - .../action/GetPluginFeaturesResponse.kt | 13 +--------- .../NotificationsPluginInterfaceTests.kt | 1 - .../action/GetPluginFeaturesResponseTests.kt | 26 +------------------ 4 files changed, 2 insertions(+), 39 deletions(-) diff --git a/src/main/kotlin/org/opensearch/commons/notifications/NotificationConstants.kt b/src/main/kotlin/org/opensearch/commons/notifications/NotificationConstants.kt index 146c48de..74fcc600 100644 --- a/src/main/kotlin/org/opensearch/commons/notifications/NotificationConstants.kt +++ b/src/main/kotlin/org/opensearch/commons/notifications/NotificationConstants.kt @@ -66,7 +66,6 @@ object NotificationConstants { const val QUERY_TAG = "query" const val COMPACT_TAG = "compact" const val ALLOWED_CONFIG_TYPE_LIST_TAG = "allowed_config_type_list" - const val ALLOWED_CONFIG_FEATURE_LIST_TAG = "allowed_config_feature_list" const val PLUGIN_FEATURES_TAG = "plugin_features" const val DEFAULT_MAX_ITEMS = 1000 diff --git a/src/main/kotlin/org/opensearch/commons/notifications/action/GetPluginFeaturesResponse.kt b/src/main/kotlin/org/opensearch/commons/notifications/action/GetPluginFeaturesResponse.kt index 1e6fa2b9..73db57a0 100644 --- a/src/main/kotlin/org/opensearch/commons/notifications/action/GetPluginFeaturesResponse.kt +++ b/src/main/kotlin/org/opensearch/commons/notifications/action/GetPluginFeaturesResponse.kt @@ -11,7 +11,6 @@ import org.opensearch.common.xcontent.ToXContent import org.opensearch.common.xcontent.XContentBuilder import org.opensearch.common.xcontent.XContentParser import org.opensearch.common.xcontent.XContentParserUtils -import org.opensearch.commons.notifications.NotificationConstants.ALLOWED_CONFIG_FEATURE_LIST_TAG import org.opensearch.commons.notifications.NotificationConstants.ALLOWED_CONFIG_TYPE_LIST_TAG import org.opensearch.commons.notifications.NotificationConstants.PLUGIN_FEATURES_TAG import org.opensearch.commons.utils.STRING_READER @@ -25,7 +24,6 @@ import java.io.IOException */ class GetPluginFeaturesResponse : BaseResponse { val allowedConfigTypeList: List - val allowedConfigFeatureList: List val pluginFeatures: Map companion object { @@ -44,7 +42,6 @@ class GetPluginFeaturesResponse : BaseResponse { @Throws(IOException::class) fun parse(parser: XContentParser): GetPluginFeaturesResponse { var allowedConfigTypeList: List? = null - var allowedConfigFeatureList: List? = null var pluginFeatures: Map? = null XContentParserUtils.ensureExpectedToken( @@ -57,7 +54,6 @@ class GetPluginFeaturesResponse : BaseResponse { parser.nextToken() when (fieldName) { ALLOWED_CONFIG_TYPE_LIST_TAG -> allowedConfigTypeList = parser.stringList() - ALLOWED_CONFIG_FEATURE_LIST_TAG -> allowedConfigFeatureList = parser.stringList() PLUGIN_FEATURES_TAG -> pluginFeatures = parser.mapStrings() else -> { parser.skipChildren() @@ -66,9 +62,8 @@ class GetPluginFeaturesResponse : BaseResponse { } } allowedConfigTypeList ?: throw IllegalArgumentException("$ALLOWED_CONFIG_TYPE_LIST_TAG field absent") - allowedConfigFeatureList ?: throw IllegalArgumentException("$ALLOWED_CONFIG_TYPE_LIST_TAG field absent") pluginFeatures ?: throw IllegalArgumentException("$PLUGIN_FEATURES_TAG field absent") - return GetPluginFeaturesResponse(allowedConfigTypeList, allowedConfigFeatureList, pluginFeatures) + return GetPluginFeaturesResponse(allowedConfigTypeList, pluginFeatures) } } @@ -78,7 +73,6 @@ class GetPluginFeaturesResponse : BaseResponse { override fun toXContent(builder: XContentBuilder?, params: ToXContent.Params?): XContentBuilder { return builder!!.startObject() .field(ALLOWED_CONFIG_TYPE_LIST_TAG, allowedConfigTypeList) - .field(ALLOWED_CONFIG_FEATURE_LIST_TAG, allowedConfigFeatureList) .field(PLUGIN_FEATURES_TAG, pluginFeatures) .endObject() } @@ -86,16 +80,13 @@ class GetPluginFeaturesResponse : BaseResponse { /** * constructor for creating the class * @param allowedConfigTypeList the list of config types supported by plugin - * @param allowedConfigFeatureList the list of config features supported by plugin * @param pluginFeatures the map of plugin features supported to its value */ constructor( allowedConfigTypeList: List, - allowedConfigFeatureList: List, pluginFeatures: Map ) { this.allowedConfigTypeList = allowedConfigTypeList - this.allowedConfigFeatureList = allowedConfigFeatureList this.pluginFeatures = pluginFeatures } @@ -105,7 +96,6 @@ class GetPluginFeaturesResponse : BaseResponse { @Throws(IOException::class) constructor(input: StreamInput) : super(input) { allowedConfigTypeList = input.readStringList() - allowedConfigFeatureList = input.readStringList() pluginFeatures = input.readMap(STRING_READER, STRING_READER) } @@ -115,7 +105,6 @@ class GetPluginFeaturesResponse : BaseResponse { @Throws(IOException::class) override fun writeTo(output: StreamOutput) { output.writeStringCollection(allowedConfigTypeList) - output.writeStringCollection(allowedConfigFeatureList) output.writeMap(pluginFeatures, STRING_WRITER, STRING_WRITER) } } diff --git a/src/test/kotlin/org/opensearch/commons/notifications/NotificationsPluginInterfaceTests.kt b/src/test/kotlin/org/opensearch/commons/notifications/NotificationsPluginInterfaceTests.kt index c71836eb..aaa831d1 100644 --- a/src/test/kotlin/org/opensearch/commons/notifications/NotificationsPluginInterfaceTests.kt +++ b/src/test/kotlin/org/opensearch/commons/notifications/NotificationsPluginInterfaceTests.kt @@ -148,7 +148,6 @@ internal class NotificationsPluginInterfaceTests { val request = mock(GetPluginFeaturesRequest::class.java) val response = GetPluginFeaturesResponse( listOf("config_type_1", "config_type_2", "config_type_3"), - listOf("config_feature_1", "config_feature_2", "config_feature_3"), mapOf( Pair("FeatureKey1", "FeatureValue1"), Pair("FeatureKey2", "FeatureValue2"), diff --git a/src/test/kotlin/org/opensearch/commons/notifications/action/GetPluginFeaturesResponseTests.kt b/src/test/kotlin/org/opensearch/commons/notifications/action/GetPluginFeaturesResponseTests.kt index 72b9a49f..1aa065a2 100644 --- a/src/test/kotlin/org/opensearch/commons/notifications/action/GetPluginFeaturesResponseTests.kt +++ b/src/test/kotlin/org/opensearch/commons/notifications/action/GetPluginFeaturesResponseTests.kt @@ -18,7 +18,6 @@ internal class GetPluginFeaturesResponseTests { actual: GetPluginFeaturesResponse ) { assertEquals(expected.allowedConfigTypeList, actual.allowedConfigTypeList) - assertEquals(expected.allowedConfigFeatureList, actual.allowedConfigFeatureList) assertEquals(expected.pluginFeatures, actual.pluginFeatures) } @@ -26,7 +25,6 @@ internal class GetPluginFeaturesResponseTests { fun `Get Response serialize and deserialize transport object should be equal`() { val response = GetPluginFeaturesResponse( listOf("config_type_1", "config_type_2", "config_type_3"), - listOf("config_feature_1", "config_feature_2", "config_feature_3"), mapOf( Pair("FeatureKey1", "FeatureValue1"), Pair("FeatureKey2", "FeatureValue2"), @@ -41,7 +39,6 @@ internal class GetPluginFeaturesResponseTests { fun `Get Response serialize and deserialize using json config object should be equal`() { val response = GetPluginFeaturesResponse( listOf("config_type_1", "config_type_2", "config_type_3"), - listOf("config_feature_1", "config_feature_2", "config_feature_3"), mapOf( Pair("FeatureKey1", "FeatureValue1"), Pair("FeatureKey2", "FeatureValue2"), @@ -57,7 +54,6 @@ internal class GetPluginFeaturesResponseTests { fun `Get Response should safely ignore extra field in json object`() { val response = GetPluginFeaturesResponse( listOf("config_type_1", "config_type_2", "config_type_3"), - listOf("config_feature_1", "config_feature_2", "config_feature_3"), mapOf( Pair("FeatureKey1", "FeatureValue1"), Pair("FeatureKey2", "FeatureValue2"), @@ -67,7 +63,6 @@ internal class GetPluginFeaturesResponseTests { val jsonString = """ { "allowed_config_type_list":["config_type_1", "config_type_2", "config_type_3"], - "allowed_config_feature_list":["config_feature_1", "config_feature_2", "config_feature_3"], "plugin_features":{ "FeatureKey1":"FeatureValue1", "FeatureKey2":"FeatureValue2", @@ -86,24 +81,6 @@ internal class GetPluginFeaturesResponseTests { fun `Get Response should throw exception if allowed_config_type_list is absent in json`() { val jsonString = """ { - "allowed_config_feature_list":["config_feature_1", "config_feature_2", "config_feature_3"], - "plugin_features":{ - "FeatureKey1":"FeatureValue1", - "FeatureKey2":"FeatureValue2", - "FeatureKey3":"FeatureValue3" - } - } - """.trimIndent() - Assertions.assertThrows(IllegalArgumentException::class.java) { - createObjectFromJsonString(jsonString) { GetPluginFeaturesResponse.parse(it) } - } - } - - @Test - fun `Get Response should throw exception if allowed_config_feature_list is absent in json`() { - val jsonString = """ - { - "allowed_config_type_list":["config_type_1", "config_type_2", "config_type_3"], "plugin_features":{ "FeatureKey1":"FeatureValue1", "FeatureKey2":"FeatureValue2", @@ -120,8 +97,7 @@ internal class GetPluginFeaturesResponseTests { fun `Get Response should throw exception if plugin_features is absent in json`() { val jsonString = """ { - "config_type_list":["config_type_1", "config_type_2", "config_type_3"], - "allowed_config_feature_list":["config_feature_1", "config_feature_2", "config_feature_3"] + "config_type_list":["config_type_1", "config_type_2", "config_type_3"] } """.trimIndent() Assertions.assertThrows(IllegalArgumentException::class.java) {