I couldn't find the info I'm looking for hence posting here for suggestion and getting to know better approach.
I have an immutable DTO object like:
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.LocalDate;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AccountCreateDto {
String name;
Long accountNo;
String email;
LocalDate dob;
String address;
Long phone;
Integer amount;
LocalDate accountOpeningDate;
Integer installmentAmount;
Integer totalAmount;
LocalDate installmentPaidDate;
@JsonCreator
public AccountCreateDto(
@JsonProperty("name") String name,
@JsonProperty("accountNo") Long accountNo,
@JsonProperty("email") String email,
@JsonProperty("dob") LocalDate dob,
@JsonProperty("address") String address,
@JsonProperty("phone") Long phone,
@JsonProperty("amount") Integer amount,
@JsonProperty("accountOpeningDate") LocalDate accountOpeningDate,
@JsonProperty("installmentAmount") Integer installmentAmount,
@JsonProperty("totalAmount") Integer totalAmount,
@JsonProperty("installmentPaidDate") LocalDate installmentPaidDate
) {
this.name = name;
this.accountNo = accountNo;
this.email = email;
this.dob = dob;
this.address = address;
this.phone = phone;
this.amount = amount;
this.accountOpeningDate = accountOpeningDate;
this.installmentAmount = installmentAmount;
this.totalAmount = totalAmount;
this.installmentPaidDate = installmentPaidDate;
}
// removing getters for brevity
}
Now I'm working on an integration test with testcontainer where I want the accountOpeningDate and installmentPaidDate to be dynamic value hence in order to set these values from Integration Tests, is it a good idea to add only 2 setters to this DTO which is only to be used for Integration Tests like below?
public void setAccountOpeningDate(LocalDate accountOpeningDate) {
this.accountOpeningDate = accountOpeningDate;
}
public void setInstallmentPaidDate(LocalDate installmentPaidDate) {
this.installmentPaidDate = installmentPaidDate;
}
Or is there a better approach than this? Looking for recommendations.
TA