withCustomTile

fun <V> withCustomTile(tile: Tile<V>, provider: suspend Mosaic.() -> V): TestMosaicBuilder(source)

Adds a mock Tile with custom behavior.

Return

This builder for method chaining

val testMosaic = mosaicBuilder()
.withCustomTile(MyTile) {
// Custom logic here
if (condition) "result1" else "result2"
}
.build()

Parameters

tile

The Tile to mock

provider

A suspending lambda that provides the response

Type Parameters

V

The type of data the tile returns


@JvmName(name = "withCustomMultiTile")
fun <K : Any, V> withCustomTile(tile: MultiTile<K, V>, provider: suspend Mosaic.(Set<K>) -> Map<K, V>): TestMosaicBuilder(source)

Adds a mock MultiTile with custom behavior.

Return

This builder for method chaining

val testMosaic = mosaicBuilder()
.withCustomTile(UserTile) { keys ->
// Custom logic based on requested keys
keys.associateWith { key ->
if (key.startsWith("admin")) createAdminUser(key)
else createRegularUser(key)
}
}
.build()

Parameters

tile

The MultiTile to mock

provider

A suspending lambda that provides responses based on requested keys

Type Parameters

K

The type of keys in the response

V

The type of values in the response