Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of an Data Factory with hard-coded data inside each factory method
public class LoanDataFactory {
private LoanDataFactory() {}
public static Loan createLoan() {
return new LoanBuilder().name("Elias").email("elias@eliasnogueira.com")
.amount(new BigDecimal("10.000")).installments(8).build();
}
public static Loan createLoanWithoutName() {
return new LoanBuilder().email("elias@eliasnogueira.com")
.amount(new BigDecimal("10.000")).installments(8).build();
}
public static Loan createLoanWithNotValidEmail() {
return new LoanBuilder().name("Elias").email("not-valid-email")
.amount(new BigDecimal("10.000")).installments(8).build();
}
public static Loan createLoanWithAmountLessThan() {
return new LoanBuilder().name("Elias").email("elias@eliasnogueira.com")
.amount(new BigDecimal("900.00")).installments(8).build();
}
// other data factories ignored
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.