diff --git a/core/src/integration/kotlin/io/github/serpro69/kfaker/UniqueDataProvierIT.kt b/core/src/integration/kotlin/io/github/serpro69/kfaker/UniqueDataProvierIT.kt index 8dee0bb62..3cb630bc0 100644 --- a/core/src/integration/kotlin/io/github/serpro69/kfaker/UniqueDataProvierIT.kt +++ b/core/src/integration/kotlin/io/github/serpro69/kfaker/UniqueDataProvierIT.kt @@ -199,8 +199,10 @@ class UniqueDataProviderIT : DescribeSpec({ context("collection of values is generated") { val faker = Faker(config) - faker.unique.enable(faker::address) - faker.unique.enable(faker::color) + faker.unique.configuration { + enable(faker::address) + enable(faker::color) + } val countries = (0..20).map { faker.address.country() } @@ -211,7 +213,7 @@ class UniqueDataProviderIT : DescribeSpec({ context("used values are cleared") { val faker = Faker(config).also { - it.unique.enable(it::address) + it.unique.configuration { enable(it::address) } } val countries = (0..20).map { faker.address.country() } @@ -231,7 +233,7 @@ class UniqueDataProviderIT : DescribeSpec({ // repeat 10 times to make sure values are not included in the collection repeat(10) { val faker = Faker(config) - faker.unique.enable(faker::address) + faker.unique.configuration { enable(faker::address) } val countries = (0..5).map { faker.address.country() } @@ -245,7 +247,7 @@ class UniqueDataProviderIT : DescribeSpec({ "Angola" ) - faker.unique.exclude
("country", excludedCountries) + faker.unique.configuration { excludeFromFunction
("country", excludedCountries) } val newCountries = (0..20).map { faker.address.country() } @@ -299,7 +301,7 @@ class UniqueDataProviderIT : DescribeSpec({ "Bouvet Island" ) - faker.unique.exclude
("country", excludedCountries) + faker.unique.configuration { excludeFromFunction
("country", excludedCountries) } val countries = (0..100).map { faker.address.country() } @@ -315,7 +317,7 @@ class UniqueDataProviderIT : DescribeSpec({ context("values are generated for another category that is not marked for unique generation") { val faker = Faker(config) - faker.unique.enable(faker::address) + faker.unique.configuration { enable(faker::address) } val colors = (0..100).map { faker.color.name() } @@ -326,10 +328,10 @@ class UniqueDataProviderIT : DescribeSpec({ context("unique generation for category is disabled") { val faker = Faker(config) - faker.unique.enable(faker::address) + faker.unique.configuration { enable(faker::address) } (0..20).map { faker.address.country() } - faker.unique.disable(faker::address) + faker.unique.configuration { disable(faker::address) } context("collection of values is generated") { val countries = (0..100).map { faker.address.country() } @@ -342,8 +344,10 @@ class UniqueDataProviderIT : DescribeSpec({ context("unique generation is disabled for all categories") { val faker = Faker(config) - faker.unique.enable(faker::address) - faker.unique.enable(faker::color) + faker.unique.configuration { + enable(faker::address) + enable(faker::color) + } faker.unique.disableAll() @@ -360,7 +364,7 @@ class UniqueDataProviderIT : DescribeSpec({ } context("unique generation for a category is re-enabled") { - faker.unique.enable(faker::address) + faker.unique.configuration { enable(faker::address) } context("collection of values is generated") { val countries = (0..20).map { faker.address.country() } @@ -374,8 +378,10 @@ class UniqueDataProviderIT : DescribeSpec({ context("unique generation is cleared for all categories") { val faker = Faker(config) - faker.unique.enable(faker::address) - faker.unique.enable(faker::color) + faker.unique.configuration { + enable(faker::address) + enable(faker::color) + } // Generate some values first (0..20).map { faker.address.country() } diff --git a/core/src/main/kotlin/io/github/serpro69/kfaker/AbstractFaker.kt b/core/src/main/kotlin/io/github/serpro69/kfaker/AbstractFaker.kt index 3d67d73d4..8798e1842 100644 --- a/core/src/main/kotlin/io/github/serpro69/kfaker/AbstractFaker.kt +++ b/core/src/main/kotlin/io/github/serpro69/kfaker/AbstractFaker.kt @@ -1,6 +1,6 @@ package io.github.serpro69.kfaker -import io.github.serpro69.kfaker.provider.unique.GlobalUniqueDataDataProvider +import io.github.serpro69.kfaker.provider.unique.GlobalUniqueDataProvider abstract class AbstractFaker(internal val config: FakerConfig) { protected val fakerService: FakerService @@ -8,7 +8,7 @@ abstract class AbstractFaker(internal val config: FakerConfig) { protected val randomService: RandomService get() = fakerService.randomService - val unique by lazy { GlobalUniqueDataDataProvider() } + val unique by lazy { GlobalUniqueDataProvider() } @FakerDsl /** diff --git a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/unique/GlobalUniqueDataDataProvider.kt b/core/src/main/kotlin/io/github/serpro69/kfaker/provider/unique/GlobalUniqueDataProvider.kt similarity index 54% rename from core/src/main/kotlin/io/github/serpro69/kfaker/provider/unique/GlobalUniqueDataDataProvider.kt rename to core/src/main/kotlin/io/github/serpro69/kfaker/provider/unique/GlobalUniqueDataProvider.kt index 4e53820b8..49ffb5a79 100644 --- a/core/src/main/kotlin/io/github/serpro69/kfaker/provider/unique/GlobalUniqueDataDataProvider.kt +++ b/core/src/main/kotlin/io/github/serpro69/kfaker/provider/unique/GlobalUniqueDataProvider.kt @@ -25,7 +25,7 @@ import kotlin.reflect.KProperty0 * ``` */ @Suppress("UNCHECKED_CAST") -class GlobalUniqueDataDataProvider internal constructor() : UniqueDataProvider() { +class GlobalUniqueDataProvider internal constructor() : UniqueDataProvider() { @JvmSynthetic @PublishedApi @@ -51,46 +51,6 @@ class GlobalUniqueDataDataProvider internal constructor() : UniqueDataProvider() config.clear(providerProperty.returnType.classifier as KClass) } - @Deprecated( - level = DeprecationLevel.WARNING, - message = "This functionality is deprecated and will be removed in release 1.8.0", - replaceWith = ReplaceWith("faker.unique.configuration { this.exclude(funcName, values) }") - ) - inline fun exclude(funcName: String, values: List) { - exclude(funcName, *values.toTypedArray()) - } - - @Deprecated( - level = DeprecationLevel.WARNING, - message = "This functionality is deprecated and will be removed in release 1.8.0", - replaceWith = ReplaceWith("faker.unique.configuration { this.exclude(funcName, values) }") - ) - inline fun exclude(funcName: String, vararg values: String) { - if (config.markedUnique.contains(T::class)) { - config.usedProviderFunctionValues[T::class]?.merge(funcName, values.toMutableSet()) { oldSet, newSet -> - oldSet.apply { addAll(newSet) } - } - } - } - - @Deprecated( - level = DeprecationLevel.WARNING, - message = "This functionality is deprecated and will be removed in release 1.8.0", - replaceWith = ReplaceWith("faker.unique.configuration { this.enable(providerProperty) }") - ) - fun enable(providerProperty: KProperty0) { - config.enable(providerProperty.returnType.classifier as KClass) - } - - @Deprecated( - level = DeprecationLevel.WARNING, - message = "This functionality is deprecated and will be removed in release 1.8.0", - replaceWith = ReplaceWith("faker.unique.configuration { this.disable(providerProperty) }") - ) - fun disable(providerProperty: KProperty0) { - config.disable(providerProperty.returnType.classifier as KClass) - } - /** * Configures `this` Unique provider. */