Skip to content

Commit

Permalink
fix client tests mocks & style
Browse files Browse the repository at this point in the history
Signed-off-by: YANGDB <[email protected]>
  • Loading branch information
YANG-DB committed Oct 19, 2023
1 parent 6dac21b commit b3e2eb5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class FlintSparkMaterializedViewITSuite extends FlintSparkSuite {
| }
| }
|""".stripMargin)
//remove test index
// remove test index
flint.deleteIndex(testTargetIndex)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()}",
Expand Down

0 comments on commit b3e2eb5

Please sign in to comment.