Skip to content

ValidationFailedException before thenApply is invoked #1225

@adambridger

Description

@adambridger

Describe the bug

thenApply is executed after an Object is built and validated using JavaxValidationPlugin resulting in ValidationFailedException. There is no way to customize the random generated object to match with complex custom constraints that span multiple fields of the Object unless specific individual fields are explicitly defined in builder to ensure Object will match custom constraint.

I have also tried setPostCondition but this is also invoked only after a successful validation.

I expect that setPostCondition, map, customizeProperty, thenApply etc are executed before the sample Object is validated against constraints.

Your environment

  • version of Fixture Monkey: 1.1.14
  • version of Java/Kotlin: JDK 21

Steps to reproduce

  1. Configure FM with JavaxValidationPlugin
  2. Configure FM with maxRetries 3
  3. Define an object with a custom constraint that depends on 2 or more fields
  4. Configure FMBuilder for the object with thenApply() to customize the random generated object to match custom constraint.
  5. Build a sample of the object

Expected behaviour

Tell us what should happen
Expect a valid object on all occurrences

Actual behaviour

ValidationFailedException on some occurrences

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions