microcks icon indicating copy to clipboard operation
microcks copied to clipboard

Do we have access to all the functions from faker library?

Open hguerrero opened this issue 4 years ago • 7 comments

Looks like for templating mocks, Microcks is using java-fake, is it possible to use any of their functions? or is it limited to a supported set?

hguerrero avatar Jun 08 '21 17:06 hguerrero

Hi @hguerrero

Correct: we're using java-fake underhood.

For integrating a new function, we need to write a simple wrapper like in RandomCityELFunction. The wrapper should then be registered into the TemplateEngineFactory.

So we actually have a limited supported set but it's very easy to add new ones ;-)

lbroudoux avatar Jun 09 '21 08:06 lbroudoux

Would it be possible to somehow dynamically try to access the underlying library for the functions to avoid this registration?

hguerrero avatar Jun 09 '21 13:06 hguerrero

Great idea! Maybe having a fallback that in case of unsupported function call tries to use reflection for java-fake invocation... It's a nice RFE.

lbroudoux avatar Jun 09 '21 14:06 lbroudoux

Any candidate for this one? It shouldn't be that difficult using basic Java reflection. It's a low hanging fruit 😉

lbroudoux avatar Jun 16 '23 12:06 lbroudoux

Greetings @lbroudoux ! I'm a beginner and any insights or resources on how can I solve this issue would be of great help. I'd like to contribute, thanks!

SaxenaAnushka102 avatar Nov 28 '23 11:11 SaxenaAnushka102

The starting idea would have been to have something like GenericFakerELFunction that would have allowed on evaluation of $randomLorem (for example) to understand that it has to invoke faker.lorem().

Thinking about it again, I don't really know if reflection is the way to go, as I don't think we have the function name at hand when evaluating the function. We may have its arguments only...

Maybe the first thing to do would be to have a review of existing faker functions and see them that is missing in Microcks in order to see how many util ones are actually missing. Depending on the number we can decide to go with static function types or think again about a more dynamic mechanism.

lbroudoux avatar Nov 28 '23 17:11 lbroudoux