Skip to content

Instantly share code, notes, and snippets.

@eliasnogueira
Created November 9, 2020 17:27
Show Gist options
  • Save eliasnogueira/89e32a0b94577dbdc7f76ff83bca6c69 to your computer and use it in GitHub Desktop.
Save eliasnogueira/89e32a0b94577dbdc7f76ff83bca6c69 to your computer and use it in GitHub Desktop.
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