Closed NBau closed 7 years ago
Here is the code that does not work for me (very simplified):
import java.util.ArrayList;
import java.util.List;
import javax.validation.constraints.Size;
import uk.co.jemos.podam.api.PodamFactory;
import uk.co.jemos.podam.api.PodamFactoryImpl;
public class Dummy {
public static void main(String[] args){
PodamFactory pf = new PodamFactoryImpl();
Pojo p = pf.manufacturePojo(Pojo.class);
System.out.println(p.dec.size()<=2);
}
public static class Pojo{
@Size(max=2)
List<Integer>dec;
public List<Integer> getDec() {
if (dec == null) {
dec = new ArrayList<>();
}
return dec;
}
}
}
The Pojo is similar to what you get when creating Java classes from an XML Schema using JAXB, so I think this pattern should be very common. Even replacing List
I did look through the test cases and it seems that there actually is no test that checks the validity of the size of the collection. All I could find were line 50 and 51, where the collections are checked for null. The size should be checked as well.
Perfect. Thank you for the good support.
Released in Podam 7.0.5
If a collection is annotated with
@Size
, this should impact the number of instances generated for this collection.