Annotation based Model Definition - TestMonkeys/jEntityTest GitHub Wiki
JEntityTest can be used with models that are respecting the standard pojo format, of having a private field with public getter/setter. The model can further be extended by annotations that define how the comparison will be performed.
Annotations can be placed either on the field or on it's getter method. The annotations and their parameters are explained here. Below is an extended example of a model:
public class User {
private String firstName;
@StringComparison(caseSensitive = false, ignoreCharacters = {'\n', '\r'})
private String lastName;
private int age;
private boolean married;
@ChildEntityListComparison
private List<Pet> pets;
@ChildEntityListComparison
private List<String> emailAddresses;
@ChildEntityComparison
private Address address;
@DateTimeComparison(delta = 1, unit = ChronoUnit.MINUTES)
private LocalDateTime createdDate;
private int id;
@IgnoreComparison
private String randomGenerated;
public String getFirstName() {
return this.firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return this.lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public int getAge() {
return this.age;
}
public void setAge(int age) {
this.age = age;
}
public boolean isMarried() {
return this.married;
}
public void setMarried(boolean married) {
this.married = married;
}
public LocalDateTime getCreatedDate() {
return this.createdDate;
}
public void setCreatedDate(LocalDateTime createdDate) {
this.createdDate = createdDate;
}
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public List<Pet> getPets() {
return this.pets;
}
public void setPets(List<Pet> pets) {
this.pets= pets;
}
public String getRandomGenerated() {
return this.randomGenerated;
}
public void setRandomGenerated(String randomGenerated) {
this.randomGenerated = randomGenerated;
}
public List<String> getEmailAddresses() {
return this.emailAddresses;
}
public void setEmailAddresses(List<String> emailAddresses) {
this.emailAddresses = emailAddresses;
}
public Address getAddress() {
return this.address;
}
public void setAddress(Address address) {
this.address = address;
}
}