public class Person {
@NotNull
private String personId;
@NotBlank
private String personName;
private Gender gender;
@Size(min = 1, max = 16)
private String personNo;
@Min(0)
private int age;
@Size(max = 5)
private List<Car> carList;
private List<String> addressList;
public enum Gender {
MAN, WOMAN
}
}
void checkPerson() {
//given
FixtureMonkey sut = FixtureMonkey.create();
//when
Person person = sut.giveMeOne(Person.class);
//then
then(person.getPersonId()).isNotNull();
then(person.getPersonName()).isNotBlank();
then(person.getPersonNo().length()).isBetween(1, 16);
...
}
void checkPerson() {
//given
FixtureMonkey sut = FixtureMonkey.create();
//when
Person person = sut.giveMeBuilder(Person.class)
.set("personId", "PERSON_ID_1")
.setNull("gender")
.setPostCondition("carList[*].price", Long.class, it -> it > 10000)
.setPostCondition("addressList[*]", String.class, it -> it.length() > 10)
.sample();
...
}
자세한 설명과 참고는 아래 사이트에서