From a5912b6c04aaffe52af96aedc5b259a37cc5e290 Mon Sep 17 00:00:00 2001 From: minwoo Date: Thu, 28 Sep 2023 19:37:25 +0900 Subject: [PATCH 1/6] feat: implement WildcardSearchOperatorDsl --- .../core/aggregation/search/SearchOperator.kt | 8 + .../aggregation/search/SearchOperatorDsl.kt | 4 + .../search/WildcardSearchOperatorDsl.kt | 104 ++++++++ .../search/WildcardSearchOperatorDslTest.kt | 236 ++++++++++++++++++ 4 files changed, 352 insertions(+) create mode 100644 core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/WildcardSearchOperatorDsl.kt create mode 100644 core/src/test/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/WildcardSearchOperatorDslTest.kt diff --git a/core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/SearchOperator.kt b/core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/SearchOperator.kt index d2605927..e1f014a3 100644 --- a/core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/SearchOperator.kt +++ b/core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/SearchOperator.kt @@ -108,4 +108,12 @@ interface SearchOperator { * @see moreLikeThis */ fun moreLikeThis(configuration: MoreLikeThisSearchOperatorDsl.() -> Unit) + + /** + * Enables queries which use special characters in the search string that can match any character. + * + * @param configuration The configuration block for the [WildcardSearchOperatorDsl]. + * @see wildcard + */ + fun wildcard(configuration: WildcardSearchOperatorDsl.() -> Unit) } diff --git a/core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/SearchOperatorDsl.kt b/core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/SearchOperatorDsl.kt index 23d01167..5bf6a2e2 100644 --- a/core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/SearchOperatorDsl.kt +++ b/core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/SearchOperatorDsl.kt @@ -53,4 +53,8 @@ class SearchOperatorDsl : SearchOperator { override fun moreLikeThis(configuration: MoreLikeThisSearchOperatorDsl.() -> Unit) { operators.add(MoreLikeThisSearchOperatorDsl().apply(configuration).build()) } + + override fun wildcard(configuration: WildcardSearchOperatorDsl.() -> Unit) { + operators.add(WildcardSearchOperatorDsl().apply(configuration).build()) + } } diff --git a/core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/WildcardSearchOperatorDsl.kt b/core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/WildcardSearchOperatorDsl.kt new file mode 100644 index 00000000..5c2b8c2d --- /dev/null +++ b/core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/WildcardSearchOperatorDsl.kt @@ -0,0 +1,104 @@ +package com.github.inflab.spring.data.mongodb.core.aggregation.search + +import com.github.inflab.spring.data.mongodb.core.annotation.AggregationMarker +import com.github.inflab.spring.data.mongodb.core.extension.firstOrAll +import com.github.inflab.spring.data.mongodb.core.extension.toDotPath +import org.bson.Document +import kotlin.reflect.KProperty + +/** + * A Kotlin DSL to configure wildcard search operator using idiomatic Kotlin code. + * + * @author minwoo + * @since 1.0 + * @see wildcard + */ +@AggregationMarker +class WildcardSearchOperatorDsl { + private val document = Document() + + /** + * Must be set to true if the query is run against an analyzed field. + */ + var allowAnalyzedField: Boolean = false + set(value) { + document["allowAnalyzedField"] = value + field = value + } + + + /** + * The string or strings to search for. + * + * @param query The string or strings to search for. + */ + fun query(vararg query: String) { + document["query"] = query.toList().firstOrAll() + } + + /** + * The indexed field or fields to search. + * You can also specify a wildcard path to search. + * See path construction for more information. + * + * @param path The indexed field or fields to search. + * @see Path Construction + */ + fun path(vararg path: String) { + document["path"] = path.toList().firstOrAll() + } + + /** + * The indexed field or fields to search. + * You can also specify a wildcard path to search. + * See path construction for more information. + * + * @param path The indexed field or fields to search. + * @see Path Construction + */ + fun path(vararg path: KProperty) { + document["path"] = path.map { it.toDotPath() }.firstOrAll() + } + + /** + * The indexed field or fields to search. + * You can also specify a wildcard path to search. + * See path construction for more information. + * + * @param path The indexed field or fields to search. + * @see Path Construction + */ + @JvmName("pathIterable") + fun path(vararg path: KProperty?>) { + document["path"] = path.map { it.toDotPath() }.firstOrAll() + } + + /** + * The indexed field or fields to search. + * You can also specify a wildcard path to search. + * See path construction for more information. + * + * @param configuration The configuration block for the [PathSearchOptionDsl]. + * @see Path Construction + */ + fun path(configuration: PathSearchOptionDsl.() -> Unit) { + document["path"] = PathSearchOptionDsl().apply(configuration).build() + } + + /** + * Score to assign to matching search results. + * You can modify the default score using the following options: + * + * - boost: multiply the result score by the given number. + * - constant: replace the result score with the given number. + * - function: replace the result score using the given expression. + * + * @see Score the Documents in the Results + */ + fun score(scoreConfiguration: ScoreSearchOptionDsl.() -> Unit) { + document["score"] = ScoreSearchOptionDsl().apply(scoreConfiguration).get() + } + + internal fun build() = Document("wildcard", document) + +} \ No newline at end of file diff --git a/core/src/test/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/WildcardSearchOperatorDslTest.kt b/core/src/test/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/WildcardSearchOperatorDslTest.kt new file mode 100644 index 00000000..033a2b04 --- /dev/null +++ b/core/src/test/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/WildcardSearchOperatorDslTest.kt @@ -0,0 +1,236 @@ +package com.github.inflab.spring.data.mongodb.core.aggregation.search + +import com.github.inflab.spring.data.mongodb.core.mapping.rangeTo +import com.github.inflab.spring.data.mongodb.core.util.shouldBeJson +import io.kotest.core.spec.style.FreeSpec +import org.springframework.data.mongodb.core.query.Query.query + +internal class WildcardSearchOperatorDslTest: FreeSpec({ + fun wildcard(block: WildcardSearchOperatorDsl.() -> Unit) = + WildcardSearchOperatorDsl().apply(block) + + "allowAnalyzedField" - { + "should set with given value" { + // given + val operator = wildcard { + allowAnalyzedField = true + } + + // when + val result = operator.build() + + // then + result.shouldBeJson( + """ + { + "wildcard": { + "allowAnalyzedField": true + } + } + """.trimIndent(), + ) + } + } + + "query" - { + "should set query by string" { + // given + val operator = wildcard { + query("query") + } + + // when + val result = operator.build() + + // then + result.shouldBeJson( + """ + { + "wildcard": { + "query": "query" + } + } + """.trimIndent(), + ) + } + + "should set query by multiple strings" { + // given + val operator = wildcard { + query("query1", "query2") + } + + // when + val result = operator.build() + + // then + result.shouldBeJson( + """ + { + "wildcard": { + "query": [ + "query1", + "query2" + ] + } + } + """.trimIndent(), + ) + } + } + + "path" - { + "should set path by strings" { + // given + val operator = wildcard { + path("path1", "path2") + } + + // when + val result = operator.build() + + // then + result.shouldBeJson( + """ + { + "wildcard": { + "path": [ + "path1", + "path2" + ] + } + } + """.trimIndent(), + ) + } + + "should set path by iterable property" { + // given + data class TestCollection(val path1: List) + val operator = wildcard { + path(TestCollection::path1) + } + + // when + val result = operator.build() + + // then + result.shouldBeJson( + """ + { + "wildcard": { + "path": "path1" + } + } + """.trimIndent(), + ) + } + + "should set path by multiple properties" { + // given + data class TestCollection(val path1: String, val path2: String) + val operator = wildcard { + path(TestCollection::path1, TestCollection::path2) + } + + // when + val result = operator.build() + + // then + result.shouldBeJson( + """ + { + "wildcard": { + "path": [ + "path1", + "path2" + ] + } + } + """.trimIndent(), + ) + } + + "should set path by nested property" { + // given + data class Child(val path: String) + data class Parent(val child: Child) + val operator = wildcard { + path(Parent::child..Child::path) + } + + // when + val result = operator.build() + + // then + result.shouldBeJson( + """ + { + "wildcard": { + "path": "child.path" + } + } + """.trimIndent(), + ) + } + + "should set path by option block" { + // given + data class TestCollection(val path1: String, val path2: List) + val operator = wildcard { + path { + +"path0" + +TestCollection::path1 + +TestCollection::path2 + } + } + + // when + val result = operator.build() + + // then + result.shouldBeJson( + """ + { + "wildcard": { + "path": [ + "path0", + "path1", + "path2" + ] + } + } + """.trimIndent(), + ) + } + } + + "score" - { + "should set score" { + // given + val operator = wildcard { + score { + constant(1.0) + } + } + + // when + val result = operator.build() + + // then + result.shouldBeJson( + """ + { + "wildcard": { + "score": { + "constant": { + "value": 1.0 + } + } + } + } + """.trimIndent(), + ) + } + } +}) \ No newline at end of file From 329215c239421c6f356f32c77471dbabeeff5551 Mon Sep 17 00:00:00 2001 From: minwoo Date: Fri, 29 Sep 2023 16:29:43 +0900 Subject: [PATCH 2/6] style: resolve ktlint --- .../mongodb/core/aggregation/search/SearchOperator.kt | 8 -------- .../core/aggregation/search/WildcardSearchOperatorDsl.kt | 4 +--- .../aggregation/search/WildcardSearchOperatorDslTest.kt | 5 ++--- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/SearchOperator.kt b/core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/SearchOperator.kt index e1f014a3..fdbd6eb1 100644 --- a/core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/SearchOperator.kt +++ b/core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/SearchOperator.kt @@ -100,14 +100,6 @@ interface SearchOperator { */ fun geoWithin(configuration: GeoWithinSearchOperatorDsl.() -> Unit) - /** - * Returns documents similar to input documents. - * The moreLikeThis operator allows you to build features for your applications that display similar or alternative results based on one or more given documents. - * - * @param configuration The configuration block for the [MoreLikeThisSearchOperatorDsl]. - * @see moreLikeThis - */ - fun moreLikeThis(configuration: MoreLikeThisSearchOperatorDsl.() -> Unit) /** * Enables queries which use special characters in the search string that can match any character. diff --git a/core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/WildcardSearchOperatorDsl.kt b/core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/WildcardSearchOperatorDsl.kt index 5c2b8c2d..a6c92945 100644 --- a/core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/WildcardSearchOperatorDsl.kt +++ b/core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/WildcardSearchOperatorDsl.kt @@ -26,7 +26,6 @@ class WildcardSearchOperatorDsl { field = value } - /** * The string or strings to search for. * @@ -100,5 +99,4 @@ class WildcardSearchOperatorDsl { } internal fun build() = Document("wildcard", document) - -} \ No newline at end of file +} diff --git a/core/src/test/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/WildcardSearchOperatorDslTest.kt b/core/src/test/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/WildcardSearchOperatorDslTest.kt index 033a2b04..c66c428c 100644 --- a/core/src/test/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/WildcardSearchOperatorDslTest.kt +++ b/core/src/test/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/WildcardSearchOperatorDslTest.kt @@ -3,9 +3,8 @@ package com.github.inflab.spring.data.mongodb.core.aggregation.search import com.github.inflab.spring.data.mongodb.core.mapping.rangeTo import com.github.inflab.spring.data.mongodb.core.util.shouldBeJson import io.kotest.core.spec.style.FreeSpec -import org.springframework.data.mongodb.core.query.Query.query -internal class WildcardSearchOperatorDslTest: FreeSpec({ +internal class WildcardSearchOperatorDslTest : FreeSpec({ fun wildcard(block: WildcardSearchOperatorDsl.() -> Unit) = WildcardSearchOperatorDsl().apply(block) @@ -233,4 +232,4 @@ internal class WildcardSearchOperatorDslTest: FreeSpec({ ) } } -}) \ No newline at end of file +}) From 6746a01e38e71256033b8c00dc922027dcdcfdad Mon Sep 17 00:00:00 2001 From: minwoo Date: Fri, 29 Sep 2023 16:30:22 +0900 Subject: [PATCH 3/6] feat: Implement WildcardSearchRepository --- .../repository/WildcardSearchRepository.kt | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 example/spring-data-mongodb/src/main/kotlin/com/github/inflab/example/spring/data/mongodb/repository/WildcardSearchRepository.kt diff --git a/example/spring-data-mongodb/src/main/kotlin/com/github/inflab/example/spring/data/mongodb/repository/WildcardSearchRepository.kt b/example/spring-data-mongodb/src/main/kotlin/com/github/inflab/example/spring/data/mongodb/repository/WildcardSearchRepository.kt new file mode 100644 index 00000000..319e823d --- /dev/null +++ b/example/spring-data-mongodb/src/main/kotlin/com/github/inflab/example/spring/data/mongodb/repository/WildcardSearchRepository.kt @@ -0,0 +1,55 @@ +package com.github.inflab.example.spring.data.mongodb.repository + +import com.github.inflab.example.spring.data.mongodb.entity.mflix.Movies +import com.github.inflab.spring.data.mongodb.core.aggregation.aggregation +import org.springframework.data.mongodb.core.MongoTemplate +import org.springframework.data.mongodb.core.aggregate +import org.springframework.data.mongodb.core.aggregation.AggregationResults +import org.springframework.stereotype.Repository + +@Repository +class WildcardSearchRepository( + private val mongoTemplate: MongoTemplate, +) { + data class TitleDto(val title: String) + + /** + * @see Example + */ + fun findTitleWithGreenD(): AggregationResults { + val aggregation = aggregation { + search { + wildcard { + path(Movies::title) + query("Green D*") + } + } + project { + excludeId() + +Movies::title + } + } + + return mongoTemplate.aggregate(aggregation) + } + + /** + * @see Escape Character Example + */ + fun findTitleWithQuestionMark(): AggregationResults { + val aggregation = aggregation { + search { + wildcard { + path(Movies::title) + query("*\\?") + } + } + project { + excludeId() + +Movies::title + } + } + + return mongoTemplate.aggregate(aggregation) + } +} From 02cfb116dc818f28b5c5595546f1989ec165a238 Mon Sep 17 00:00:00 2001 From: minwoo Date: Fri, 29 Sep 2023 16:30:31 +0900 Subject: [PATCH 4/6] test: add WildcardSearchRepositoryTest --- .../WildcardSearchRepositoryTest.kt | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 example/spring-data-mongodb/src/test/kotlin/com/github/inflab/example/spring/data/mongodb/repository/WildcardSearchRepositoryTest.kt diff --git a/example/spring-data-mongodb/src/test/kotlin/com/github/inflab/example/spring/data/mongodb/repository/WildcardSearchRepositoryTest.kt b/example/spring-data-mongodb/src/test/kotlin/com/github/inflab/example/spring/data/mongodb/repository/WildcardSearchRepositoryTest.kt new file mode 100644 index 00000000..03d4d2bc --- /dev/null +++ b/example/spring-data-mongodb/src/test/kotlin/com/github/inflab/example/spring/data/mongodb/repository/WildcardSearchRepositoryTest.kt @@ -0,0 +1,33 @@ +package com.github.inflab.example.spring.data.mongodb.repository + +import com.github.inflab.example.spring.data.mongodb.extension.AtlasTest +import io.kotest.core.annotation.Ignored +import io.kotest.core.spec.style.FreeSpec +import io.kotest.matchers.shouldBe +import io.kotest.matchers.string.shouldContain + +@Ignored +@AtlasTest(database = "sample_mflix") +internal class WildcardSearchRepositoryTest( + private val wildcardSearchRepository: WildcardSearchRepository, +) : FreeSpec({ + + "findTitleWithGreenD" { + // when + val result = wildcardSearchRepository.findTitleWithGreenD() + + // then + result.mappedResults.map { it.title } shouldBe listOf( + "Green Dolphin Street", + "Green Dragon", + ) + } + + "findTitleWithQuestionMark" { + // when + val result = wildcardSearchRepository.findTitleWithQuestionMark() + + // then + result.mappedResults.map { it.title shouldContain "?" } + } +}) From af8c834242192d2d60b8c8c83216daab695ce190 Mon Sep 17 00:00:00 2001 From: minwoo Date: Fri, 29 Sep 2023 16:37:25 +0900 Subject: [PATCH 5/6] feat: resolve conflict --- .../mongodb/core/aggregation/search/SearchOperator.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/SearchOperator.kt b/core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/SearchOperator.kt index fdbd6eb1..e1f014a3 100644 --- a/core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/SearchOperator.kt +++ b/core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/SearchOperator.kt @@ -100,6 +100,14 @@ interface SearchOperator { */ fun geoWithin(configuration: GeoWithinSearchOperatorDsl.() -> Unit) + /** + * Returns documents similar to input documents. + * The moreLikeThis operator allows you to build features for your applications that display similar or alternative results based on one or more given documents. + * + * @param configuration The configuration block for the [MoreLikeThisSearchOperatorDsl]. + * @see moreLikeThis + */ + fun moreLikeThis(configuration: MoreLikeThisSearchOperatorDsl.() -> Unit) /** * Enables queries which use special characters in the search string that can match any character. From 0e0f74a2cf929a4631e183dd64253b0b619f2a9d Mon Sep 17 00:00:00 2001 From: minwoo Date: Sat, 30 Sep 2023 15:36:32 +0900 Subject: [PATCH 6/6] test: apply style guide --- .../search/WildcardSearchOperatorDslTest.kt | 18 +++++++++--------- .../{ => atlas}/WildcardSearchRepository.kt | 5 ++++- .../WildcardSearchRepositoryTest.kt | 13 ++++++++----- 3 files changed, 21 insertions(+), 15 deletions(-) rename example/spring-data-mongodb/src/main/kotlin/com/github/inflab/example/spring/data/mongodb/repository/{ => atlas}/WildcardSearchRepository.kt (97%) rename example/spring-data-mongodb/src/test/kotlin/com/github/inflab/example/spring/data/mongodb/repository/{ => atlas}/WildcardSearchRepositoryTest.kt (74%) diff --git a/core/src/test/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/WildcardSearchOperatorDslTest.kt b/core/src/test/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/WildcardSearchOperatorDslTest.kt index c66c428c..03ec1c5e 100644 --- a/core/src/test/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/WildcardSearchOperatorDslTest.kt +++ b/core/src/test/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/WildcardSearchOperatorDslTest.kt @@ -9,7 +9,7 @@ internal class WildcardSearchOperatorDslTest : FreeSpec({ WildcardSearchOperatorDsl().apply(block) "allowAnalyzedField" - { - "should set with given value" { + "should build an option with given value" { // given val operator = wildcard { allowAnalyzedField = true @@ -32,7 +32,7 @@ internal class WildcardSearchOperatorDslTest : FreeSpec({ } "query" - { - "should set query by string" { + "should build a query by string" { // given val operator = wildcard { query("query") @@ -53,7 +53,7 @@ internal class WildcardSearchOperatorDslTest : FreeSpec({ ) } - "should set query by multiple strings" { + "should build a query by multiple strings" { // given val operator = wildcard { query("query1", "query2") @@ -79,7 +79,7 @@ internal class WildcardSearchOperatorDslTest : FreeSpec({ } "path" - { - "should set path by strings" { + "should build a path by strings" { // given val operator = wildcard { path("path1", "path2") @@ -103,7 +103,7 @@ internal class WildcardSearchOperatorDslTest : FreeSpec({ ) } - "should set path by iterable property" { + "should build a path by iterable property" { // given data class TestCollection(val path1: List) val operator = wildcard { @@ -125,7 +125,7 @@ internal class WildcardSearchOperatorDslTest : FreeSpec({ ) } - "should set path by multiple properties" { + "should build a path by multiple properties" { // given data class TestCollection(val path1: String, val path2: String) val operator = wildcard { @@ -150,7 +150,7 @@ internal class WildcardSearchOperatorDslTest : FreeSpec({ ) } - "should set path by nested property" { + "should build a path by nested property" { // given data class Child(val path: String) data class Parent(val child: Child) @@ -173,7 +173,7 @@ internal class WildcardSearchOperatorDslTest : FreeSpec({ ) } - "should set path by option block" { + "should build a path by option block" { // given data class TestCollection(val path1: String, val path2: List) val operator = wildcard { @@ -205,7 +205,7 @@ internal class WildcardSearchOperatorDslTest : FreeSpec({ } "score" - { - "should set score" { + "should build a score" { // given val operator = wildcard { score { diff --git a/example/spring-data-mongodb/src/main/kotlin/com/github/inflab/example/spring/data/mongodb/repository/WildcardSearchRepository.kt b/example/spring-data-mongodb/src/main/kotlin/com/github/inflab/example/spring/data/mongodb/repository/atlas/WildcardSearchRepository.kt similarity index 97% rename from example/spring-data-mongodb/src/main/kotlin/com/github/inflab/example/spring/data/mongodb/repository/WildcardSearchRepository.kt rename to example/spring-data-mongodb/src/main/kotlin/com/github/inflab/example/spring/data/mongodb/repository/atlas/WildcardSearchRepository.kt index 319e823d..5210da71 100644 --- a/example/spring-data-mongodb/src/main/kotlin/com/github/inflab/example/spring/data/mongodb/repository/WildcardSearchRepository.kt +++ b/example/spring-data-mongodb/src/main/kotlin/com/github/inflab/example/spring/data/mongodb/repository/atlas/WildcardSearchRepository.kt @@ -1,4 +1,4 @@ -package com.github.inflab.example.spring.data.mongodb.repository +package com.github.inflab.example.spring.data.mongodb.repository.atlas import com.github.inflab.example.spring.data.mongodb.entity.mflix.Movies import com.github.inflab.spring.data.mongodb.core.aggregation.aggregation @@ -44,6 +44,9 @@ class WildcardSearchRepository( query("*\\?") } } + + // TODO: add $limit stage + project { excludeId() +Movies::title diff --git a/example/spring-data-mongodb/src/test/kotlin/com/github/inflab/example/spring/data/mongodb/repository/WildcardSearchRepositoryTest.kt b/example/spring-data-mongodb/src/test/kotlin/com/github/inflab/example/spring/data/mongodb/repository/atlas/WildcardSearchRepositoryTest.kt similarity index 74% rename from example/spring-data-mongodb/src/test/kotlin/com/github/inflab/example/spring/data/mongodb/repository/WildcardSearchRepositoryTest.kt rename to example/spring-data-mongodb/src/test/kotlin/com/github/inflab/example/spring/data/mongodb/repository/atlas/WildcardSearchRepositoryTest.kt index 03d4d2bc..efac91bb 100644 --- a/example/spring-data-mongodb/src/test/kotlin/com/github/inflab/example/spring/data/mongodb/repository/WildcardSearchRepositoryTest.kt +++ b/example/spring-data-mongodb/src/test/kotlin/com/github/inflab/example/spring/data/mongodb/repository/atlas/WildcardSearchRepositoryTest.kt @@ -1,12 +1,9 @@ -package com.github.inflab.example.spring.data.mongodb.repository +package com.github.inflab.example.spring.data.mongodb.repository.atlas import com.github.inflab.example.spring.data.mongodb.extension.AtlasTest -import io.kotest.core.annotation.Ignored import io.kotest.core.spec.style.FreeSpec import io.kotest.matchers.shouldBe -import io.kotest.matchers.string.shouldContain -@Ignored @AtlasTest(database = "sample_mflix") internal class WildcardSearchRepositoryTest( private val wildcardSearchRepository: WildcardSearchRepository, @@ -28,6 +25,12 @@ internal class WildcardSearchRepositoryTest( val result = wildcardSearchRepository.findTitleWithQuestionMark() // then - result.mappedResults.map { it.title shouldContain "?" } + result.mappedResults.take(5).map { it.title } shouldBe listOf( + "Where Are My Children?", + "Who Killed Cock Robin?", + "What's Opera, Doc?", + "Will Success Spoil Rock Hunter?", + "Who Was That Lady?", + ) } })