Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FailoverIntrospector produces different results #1140

Open
esfomeado opened this issue Jan 7, 2025 · 3 comments
Open

FailoverIntrospector produces different results #1140

esfomeado opened this issue Jan 7, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@esfomeado
Copy link
Contributor

Describe the bug

When using a FailoverIntrospector the generation fails when generating a record.

This fails:

FixtureMonkey.builder()
                .useExpressionStrictMode()
                .objectIntrospector(new FailoverIntrospector(List.of(FieldReflectionArbitraryIntrospector.INSTANCE), true))
                .pushAssignableTypeArbitraryIntrospector(Record.class, ConstructorPropertiesArbitraryIntrospector.INSTANCE)
               .build();

This works (The only difference is the FailoverIntrospector):

FixtureMonkey.builder()
                .useExpressionStrictMode()
                .objectIntrospector(FieldReflectionArbitraryIntrospector.INSTANCE)
                .pushAssignableTypeArbitraryIntrospector(Record.class, ConstructorPropertiesArbitraryIntrospector.INSTANCE)
               .build();

Your environment

  • Fixture Monkey 1.1.6
  • Java 21

Steps to reproduce

I´m unable to replicate this issue standalone. Here works fine but it fails in my production code.

https://github.com/esfomeado/fixture-monkey-bug/blob/master/src/test/java/com/example/bug/FixtureMonkeyTest.java#L157

Most likely something else is conflicting with this.

Expected behaviour

Should generate the value just fine

Actual behaviour

It fails to generate, no error but all fields are null

@esfomeado esfomeado added the bug Something isn't working label Jan 7, 2025
@esfomeado
Copy link
Contributor Author

@seongahjo
Copy link
Contributor

@esfomeado

Thank you for providing a reproducible example.

The result of FailoverIntrospector is intended.
When using the FailoverIntrospector, you must specify the PropertyGenerator while FieldReflectionArbitraryIntrospector provides the default PropertyGenerator.

You switch the FieldReflectionArbitraryIntrospector to FailoverIntrospector, so the properties generated by FieldReflectionArbitraryIntrospector are gone.

However, there is a bug when generating a record instance with two constructors. Let you know when it is fixed.

Thank you.

@esfomeado
Copy link
Contributor Author

  • I have specified .pushAssignableTypeArbitraryIntrospector(Record.class, ConstructorPropertiesArbitraryIntrospector.INSTANCE), so I would expect all Records to be generated using this generator and not via the FailoverIntrospector. If I remove that FailoverIntrospector that is how it behaves but when I add it the behavior changes.

  • Seems wrong having to specify a PropertyGenerator. Each Introspector was their own way of generating properties and the FailoverIntrospector should let the Introspector use their own.

  • Otherwise what´s the point of using the FailoverIntrospector? From my point of view the FailoverIntrospector should just call each Introspector until one was able to generate the value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants