naver / fixture-monkey

Let Fixture Monkey generate test instances including edge cases automatically
https://naver.github.io/fixture-monkey
Apache License 2.0
550 stars 84 forks source link

Interface subtypes #1008

Closed esfomeado closed 1 week ago

esfomeado commented 1 month ago

Hello,

Before version 1.0.21 I was using reflection to get all subtypes of a class like this:

    private static MatcherOperator<ObjectPropertyGenerator> interfacePropertyGenerator()
    {
        return new MatcherOperator<>( property -> isTypeAbstract( property.getType() ),
                                      property -> new InterfaceObjectPropertyGenerator<>( getSubtypes( property.getProperty().getType() ) ).generate( property ) );
    }

    FixtureMonkey.builder().pushObjectPropertyGenerator( interfacePropertyGenerator() )

But now InterfaceObjectPropertyGenerator is deprecated and I have to use InterfaceCandidateConcretePropertyResolver and it seems that I can now only setup interfaces using the pushExactTypePropertyCandidateResolver.

The issue with that is that I have to list all interfaces that I have on my project which is cumbersome. Is there any other way of doing this that I'm missing?

Thanks

seongahjo commented 1 month ago

@esfomeado Hello.

The pushPropertyCandidateResolver option for this case will be added in 1.1.0 like other options. Since the option can be nested, I need more tests.

Thank you

seongahjo commented 2 weeks ago

@esfomeado Hello, sorry for the confusion. All the interface options are now in InterfacePlugin.

Please use the option interfaceImplements(Matcher, CandidateConcretePropertyResolver) in 1.0.23. You can find out more here

Thank you for waiting!

esfomeado commented 1 week ago

Thanks