mtedone / podam

PODAM - POjo DAta Mocker
https://mtedone.github.io/podam
MIT License
326 stars 749 forks source link

Add attribute strategy store #307

Closed NikitaKochkurov closed 2 years ago

NikitaKochkurov commented 2 years ago

Abstract AttributeStrategyStore helps add AttributeStrategy without adding annotation @PodamStrategyValue. This is needed for existing classes from the library, which required specify value for return.

For example:
AttributeStrategyStore.setAttributeStrategyForField(Test.class, "name", new PostCodeStrategy());

Need specify: class, field name and strategy

Sorry if I didn't see an existing way to specify values ​​for library classes, then please close PR.

If that PR make sense, I'll continue develop (adding: tests: javadoc ...).

Please consider my request.

Best regards, Nikita Kochkurov

daivanov commented 2 years ago

Hi,

I implemented this feature separately inside of DataProviderStrategy, which defines all PodamFactory behaviour. Now it can be used the following way:

podamFactory.getStrategy().addOrReplaceAttributeStrategy(Test.class, "name", new PostCodeStrategy()); Thanks, Daniil

daivanov commented 2 years ago

The feature is available in podam-7.2.10-SNAPSHOT.

Thanks, Daniil