mtedone / podam

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

BeanValidationStrategy support for Digits and DecimalMin/Max annotations broken #223

Closed NBau closed 7 years ago

NBau commented 7 years ago

I think the minimum and maximum need to be calculated from the combination of the @Digits and @DecimalMax/Min values.

daivanov commented 7 years ago

Thank you for reporting this issue, I will look into this.

daivanov commented 7 years ago

Could you please try 7.0.3 snapshot https://oss.sonatype.org/content/repositories/snapshots/uk/co/jemos/podam/podam/7.0.3-SNAPSHOT/podam-7.0.3-20161125.185719-1.jar ?

NBau commented 7 years ago

Thank you for the quick reply. It looks like you fixed the issue. Perfect!

NBau commented 7 years ago

Oh, actually I just saw that there is still one issue remaining: when just setting the @Digits, the random value will never be negative. The reason is that min is initialized with Double.MIN_VALUE, (line 127) which is defined as 2E-1074, i.e. just a little above 0. When calculating the min based on the @Digits, it is set to max.negate().max(min); (line 160). The statement in line 160 is correct, but the min should be initialized with -Double.MAX_VALUE in line 127 to make sure that the correct minimum is set.

daivanov commented 7 years ago

Nope, line 160 wasn't fine... https://oss.sonatype.org/content/repositories/snapshots/uk/co/jemos/podam/podam/7.0.3-SNAPSHOT/podam-7.0.3-20161126.194126-2.jar

NBau commented 7 years ago

Ok, that seems to have fixed the issue. Thank you again for the great support.