io.github.hellocuriosity.ModelForgeKotlin.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of model-forge Show documentation
Show all versions of model-forge Show documentation
Model Forge is a library to automate model generation for automated testing.
The newest version!
package io.github.hellocuriosity
import javax.inject.Provider
import kotlin.reflect.KClass
/**
* Creates an automatically generated model object
*
* @param Type to instantiate
* @param clazz Class to instantiate
*
* @return Instance of clazz
*/
public fun ModelForge.build(clazz: KClass): T = build(clazz.java)
/**
* Creates an automatically generated model list with
* or without a specified size.
*
* @param Type to instantiate
* @param clazz Class to instantiate
* @param size Int number of models to create (defaulting to 10)
*
* @return Instance of clazz
*/
public fun ModelForge.buildList(
clazz: KClass,
size: Int = 10,
): List = buildList(clazz.java, size)
/**
* Creates an automatically generated model set with
* or without a specified size.
*
* @param Type to instantiate
* @param clazz Class to instantiate
* @param size Int number of models to create (defaulting to 10)
*
* @return Instance of clazz
*/
public fun ModelForge.buildSet(
clazz: KClass,
size: Int = 10,
): Set = buildSet(clazz.java, size)
/**
* Adds a custom provider for generating models
*
* @param Type to instantiate
* @param clazz Class to instantiate
* @param provider Provider for populating data
*
*/
public fun ModelForge.addProvider(
clazz: KClass,
provider: Provider,
) = addProvider(clazz.java, provider)
public inline fun ModelForge.build(): T = build(T::class)
public inline fun ModelForge.buildList(size: Int = 10): List = buildList(T::class, size)
public inline fun ModelForge.buildSet(size: Int = 10): Set = buildSet(T::class, size)
© 2015 - 2025 Weber Informatics LLC | Privacy Policy