mtedone / podam

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

pass actual annotation to an AttributeStrategy to allow customization #237

Closed NBau closed 6 years ago

NBau commented 7 years ago

Since the generic case for supporting @Pattern as described in #218 will probably not be available very soon, a temporary enhancement could be to support providing custom manufacturers for specific patterns. Right now, I cannot see an easy way to provide such a manufacturer since, e.g. the AttributeStrategy does not get passed the instance of the annotation in the getValue method.

daivanov commented 7 years ago

And why do we have two issues for the same problem? Please, use issue #218, which is already open.

NBau commented 7 years ago

Sorry, I was not sure how to do it differently. My idea was, instead of trying to solve the issue in #218 (I.e. Have a general way of supporting all patterns), just provide a way to register individual manufacturers for different patterns. This way, someone who wants to use the library but has some particular pattern annotation can hand-craft a specific manufacturer just for this case. Just like a custom type manufacturer. Unfortunately, this is not possible right now, since the AttributeStrategy does not have access to the annotation instance. Additionally, this would allow to support other custom Annotations as well.

On 6 Feb 2017, at 18:43, Daniil Ivanov notifications@github.com wrote:

And why do we have two issues for the same problem?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

daivanov commented 7 years ago

Some improvements to the issue was released in Podam 7.0.5.

dedece35 commented 6 years ago

As @daivanov said and with last release of Podam (7.1.0.RELEASE), I tested and succedded to customize my Tests using POJOs containing @Pattern annotation. I did this with a Strategy like in Tests written by @daivanov in commit https://github.com/daivanov/joinmo/commit/79be6f88d167cfcd20bad8e4b52533b90ac19bdd I think @daivanov you can close this issue.

daivanov commented 6 years ago

Yes, I assume this was about custom annotation handlers. But for generic pattern support with some library we have Issue #218.