From b3e2eb50ca337d67bd57f23bb4e7e3aae32a5594 Mon Sep 17 00:00:00 2001 From: YANGDB Date: Wed, 18 Oct 2023 19:57:56 -0700 Subject: [PATCH] fix client tests mocks & style Signed-off-by: YANGDB --- .../opensearch/flint/core/FlintOpenSearchClientSuite.scala | 6 ++++-- .../flint/spark/FlintSparkCoveringIndexSqlITSuite.scala | 2 +- .../flint/spark/FlintSparkMaterializedViewITSuite.scala | 2 +- .../flint/spark/FlintSparkSkippingIndexITSuite.scala | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/integ-test/src/test/scala/org/opensearch/flint/core/FlintOpenSearchClientSuite.scala b/integ-test/src/test/scala/org/opensearch/flint/core/FlintOpenSearchClientSuite.scala index 779e025f6..ab683980c 100644 --- a/integ-test/src/test/scala/org/opensearch/flint/core/FlintOpenSearchClientSuite.scala +++ b/integ-test/src/test/scala/org/opensearch/flint/core/FlintOpenSearchClientSuite.scala @@ -10,6 +10,7 @@ import scala.collection.JavaConverters._ import org.json4s.{Formats, NoTypeHints} import org.json4s.native.JsonMethods.parse import org.json4s.native.Serialization +import org.mockito.ArgumentMatchers.anyBoolean import org.mockito.Mockito.when import org.opensearch.client.json.jackson.JacksonJsonpMapper import org.opensearch.client.opensearch.OpenSearchClient @@ -46,8 +47,9 @@ class FlintOpenSearchClientSuite extends AnyFlatSpec with OpenSearchSuite with M |""".stripMargin val metadata = mock[FlintMetadata] - when(metadata.getContent()).thenReturn(content) + when(metadata.getContent(anyBoolean())).thenReturn(content) when(metadata.indexSettings).thenReturn(None) + when(metadata.targetName).thenReturn(None) flintClient.createIndex(indexName, metadata) flintClient.exists(indexName) shouldBe true @@ -58,7 +60,7 @@ class FlintOpenSearchClientSuite extends AnyFlatSpec with OpenSearchSuite with M val indexName = "flint_test_with_settings" val indexSettings = "{\"number_of_shards\": 3,\"number_of_replicas\": 2}" val metadata = mock[FlintMetadata] - when(metadata.getContent()).thenReturn("{}") + when(metadata.getContent(anyBoolean())).thenReturn("{}") when(metadata.indexSettings).thenReturn(Some(indexSettings)) flintClient.createIndex(indexName, metadata) diff --git a/integ-test/src/test/scala/org/opensearch/flint/spark/FlintSparkCoveringIndexSqlITSuite.scala b/integ-test/src/test/scala/org/opensearch/flint/spark/FlintSparkCoveringIndexSqlITSuite.scala index 7e8481464..d3774eb37 100644 --- a/integ-test/src/test/scala/org/opensearch/flint/spark/FlintSparkCoveringIndexSqlITSuite.scala +++ b/integ-test/src/test/scala/org/opensearch/flint/spark/FlintSparkCoveringIndexSqlITSuite.scala @@ -252,7 +252,7 @@ class FlintSparkCoveringIndexSqlITSuite extends FlintSparkSuite { (settings \ "index.number_of_shards").extract[String] shouldBe "2" (settings \ "index.number_of_replicas").extract[String] shouldBe "3" - //remove test index + // remove test index flint.deleteIndex(targetIndex) } diff --git a/integ-test/src/test/scala/org/opensearch/flint/spark/FlintSparkMaterializedViewITSuite.scala b/integ-test/src/test/scala/org/opensearch/flint/spark/FlintSparkMaterializedViewITSuite.scala index 24fbb62ec..1377c2384 100644 --- a/integ-test/src/test/scala/org/opensearch/flint/spark/FlintSparkMaterializedViewITSuite.scala +++ b/integ-test/src/test/scala/org/opensearch/flint/spark/FlintSparkMaterializedViewITSuite.scala @@ -230,7 +230,7 @@ class FlintSparkMaterializedViewITSuite extends FlintSparkSuite { | } | } |""".stripMargin) - //remove test index + // remove test index flint.deleteIndex(testTargetIndex) } diff --git a/integ-test/src/test/scala/org/opensearch/flint/spark/FlintSparkSkippingIndexITSuite.scala b/integ-test/src/test/scala/org/opensearch/flint/spark/FlintSparkSkippingIndexITSuite.scala index 40de6e223..bb6282fb4 100644 --- a/integ-test/src/test/scala/org/opensearch/flint/spark/FlintSparkSkippingIndexITSuite.scala +++ b/integ-test/src/test/scala/org/opensearch/flint/spark/FlintSparkSkippingIndexITSuite.scala @@ -7,6 +7,7 @@ package org.opensearch.flint.spark import com.stephenn.scalatest.jsonassert.JsonMatchers.matchJson import org.json4s.native.JsonMethods._ +import org.mockito.ArgumentMatchers.anyBoolean import org.opensearch.flint.core.FlintVersion.current import org.opensearch.flint.spark.FlintSpark.RefreshMode.{FULL, INCREMENTAL} import org.opensearch.flint.spark.FlintSparkIndex.ID_COLUMN @@ -446,7 +447,7 @@ class FlintSparkSkippingIndexITSuite extends FlintSparkSuite { val index = flint.describeIndex(testIndex) index shouldBe defined - index.get.metadata().getContent() should matchJson(s"""{ + index.get.metadata().getContent(anyBoolean()) should matchJson(s"""{ | "_meta": { | "name": "flint_spark_catalog_default_data_type_table_skipping_index", | "version": "${current()}",