Skip to content

[Kotlin] Recursive non-null generation for Kotlin nullable types? #1218

Closed Answered by gerardbosch
gerardbosch asked this question in Q&A
Discussion options

You must be logged in to vote

For anyone interested I found the way to configure it. Though the code is in Kotlin, it works for both Kotlin and Java complex nested objects:

  /**
   * Generates a FixtureMonkey builder for the specified type, using the FixtureMonkey instance configured for Kotlin.
   *
   * @param noNulls If true, the generated instance fields will not contain any null values (recursive). Defaults to
   *     false as the option makes more sense for Java objects.
   * @return A test fixture builder that allows to customize the generated object.
   */
  inline fun <reified A> fixtBuilder(noNulls: Boolean = false)  =
    fixtMonkeyBuilder
      //.defaultNotNull(noNulls) // <-- this is not honored in Kot…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@seongahjo
Comment options

@gerardbosch
Comment options

@gerardbosch
Comment options

Answer selected by gerardbosch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants