mtedone / podam

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

Custom PodamFactory that was working with 7.0.5.RELEASE stopped working with 7.1.1.RELEASE #266

Closed buraequete closed 6 years ago

buraequete commented 6 years ago

The custom factory I am creating is as follows, updated for latest version;

static PodamFactory buildBeanFactory() {
    PodamFactoryImpl factory = new PodamFactoryImpl((new AbstractRandomDataProviderStrategy(1) {
        @Override
        public int getMaxDepth(Class<?> type) {
            return -1;
        }
    }));
    ((RandomDataProviderStrategy) factory.getStrategy())
            .addOrReplaceAttributeStrategy(PatternA.class, new PatternAStrategy())
            .addOrReplaceAttributeStrategy(PatternB.class, new PatternBStrategy())
            .addOrReplaceAttributeStrategy(PatternC.class, new PatternCStrategy())
            .addOrReplaceTypeManufacturer(LocalDateTime.class, (s, m, map) -> LocalDateTime.now().truncatedTo(ChronoUnit.SECONDS))
    return factory;
}

& the manufacture method does work, but basic type manufacturers are not working, any field but those targeted by above custom strategies are null; String, Boolean, Integer etc. fields without any annotations. I am unable to debug podam source code directly at this moment

I am not sure of the reason, I have no other configuration but above factory, then I simply do

factory.manufacturePojo(pojoClass)
daivanov commented 6 years ago

Hi,

Your report doesn't provide any insight on the problem. Podam has pretty good log, why would not you provide it?

Thanks, Daniil

daivanov commented 6 years ago

Yes, and you definitely want to remove getMaxDepth -1.

buraequete commented 6 years ago

Hello,

Sorry, I haven't had time to debug, also the Podam log was being hidden, but with the removal of getMaxDepth -1, now it works properly, previously I used that value to stop cyclic cases with JPA, but latest version was breaking with it, also I found out some improper generation of my previous test cases. So the issue can be closed, sorry for posting without very little content!

daivanov commented 6 years ago

Ok, thank you.