Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.navercorp.fixturemonkey.kotlin.KFunctionExtensions.kt Maven / Gradle / Ivy
Go to download
The easiest way to generate controllable arbitrary test objects
@file:Suppress("unused", "UNUSED_PARAMETER")
package com.navercorp.fixturemonkey.kotlin
import com.navercorp.fixturemonkey.ArbitraryBuilder
import com.navercorp.fixturemonkey.Constants
import java.util.function.Predicate
import java.util.function.Supplier
import kotlin.reflect.KFunction1
fun ArbitraryBuilder.setExpGetter(property: KFunction1, value: Any?): ArbitraryBuilder =
this.set(propertyExpressionGenerator(property), value)
fun ArbitraryBuilder.setExpGetter(property: KFunction1, value: Any?, limit: Long): ArbitraryBuilder =
this.set(
propertyExpressionGenerator(property),
value,
limit.toInt()
)
fun ArbitraryBuilder.setNullExpGetter(property: KFunction1): ArbitraryBuilder =
this.setNull(propertyExpressionGenerator(property))
fun ArbitraryBuilder.setNotNullExpGetter(property: KFunction1): ArbitraryBuilder =
this.setNotNull(propertyExpressionGenerator(property))
fun ArbitraryBuilder.setPostConditionExpGetter(
property: KFunction1,
clazz: Class,
filter: Predicate,
limit: Long
): ArbitraryBuilder =
this.setPostCondition(
propertyExpressionGenerator(property),
clazz,
filter,
limit.toInt()
)
fun ArbitraryBuilder.setPostConditionExpGetter(
property: KFunction1,
clazz: Class,
filter: Predicate
): ArbitraryBuilder =
this.setPostCondition(
propertyExpressionGenerator(property),
clazz,
filter
)
fun ArbitraryBuilder.sizeExpGetter(
property: KFunction1,
size: Int
): ArbitraryBuilder =
this.size(propertyExpressionGenerator(property), size)
fun ArbitraryBuilder.sizeExpGetter(
property: KFunction1,
min: Int,
max: Int
): ArbitraryBuilder =
this.size(propertyExpressionGenerator(property), min, max)
fun ArbitraryBuilder.minSizeExpGetter(
property: KFunction1,
min: Int
): ArbitraryBuilder =
this.minSize(propertyExpressionGenerator(property), min)
fun ArbitraryBuilder.maxSizeExpGetter(
property: KFunction1,
max: Int
): ArbitraryBuilder =
this.maxSize(propertyExpressionGenerator(property), max)
fun ArbitraryBuilder.setLazyExpGetter(
property: KFunction1,
supplier: Supplier
): ArbitraryBuilder =
this.setLazy(propertyExpressionGenerator(property), supplier)
fun ArbitraryBuilder.setLazyExpGetter(
property: KFunction1,
supplier: Supplier,
limit: Long
): ArbitraryBuilder =
this.setLazy(propertyExpressionGenerator(property), supplier, limit.toInt())
// root
@JvmName("setRootExpGetter")
fun ArbitraryBuilder.setExpGetter(
property: KFunction1>,
value: Any?,
limit: Long = Constants.MAX_MANIPULATION_COUNT.toLong()
): ArbitraryBuilder =
this.set("$", value, limit.toInt())
@JvmName("setNullRootExpGetter")
fun ArbitraryBuilder.setNullExpGetter(property: KFunction1>): ArbitraryBuilder =
this.setNull("$")
@JvmName("setNotNullRootExpGetter")
fun ArbitraryBuilder.setNotNullExpGetter(property: KFunction1>): ArbitraryBuilder =
this.setNotNull("$")
@JvmName("sizeRootExpGetter")
fun ArbitraryBuilder.sizeExpGetter(
property: KFunction1>,
size: Int
): ArbitraryBuilder =
this.size("$", size)
@JvmName("sizeRootExpGetter")
fun ArbitraryBuilder.sizeExpGetter(
property: KFunction1>,
min: Int,
max: Int
): ArbitraryBuilder =
this.size("$", min, max)
@JvmName("minSizeRootExpGetter")
fun ArbitraryBuilder.minSizeExpGetter(
property: KFunction1>,
min: Int
): ArbitraryBuilder = this.minSize("$", min)
@JvmName("maxSizeRootExpGetter")
fun ArbitraryBuilder.maxSizeExpGetter(
property: KFunction1>,
max: Int
): ArbitraryBuilder = this.maxSize("$", max)
inline fun ArbitraryBuilder.setPostConditionExpGetter(
property: KFunction1>,
filter: Predicate,
limit: Long = Constants.MAX_MANIPULATION_COUNT.toLong()
): ArbitraryBuilder =
this.setPostCondition(
"$",
T::class.java,
filter,
limit.toInt()
)
@JvmName("setLazyRootExpGetter")
fun ArbitraryBuilder.setLazyExpGetter(
property: KFunction1>,
supplier: Supplier,
limit: Long = Constants.MAX_MANIPULATION_COUNT.toLong()
): ArbitraryBuilder = this.setLazy("$", supplier, limit.toInt())