Last active
June 12, 2021 09:11
-
-
Save lovewithmind/607092bfd8c44e56e8b79d582368406b to your computer and use it in GitHub Desktop.
Lombok builder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PersonTest { | |
@Test | |
public void shouldReturnFalseForInCorrectEmail() { | |
Person person = PersonTestData.defaultBuilder() | |
.email("abc123") | |
.build(); | |
boolean isValidEmail = person.isValidEmail(); | |
assertFalse(isValidEmail); | |
} | |
} | |
class PersonTestData extends Person { | |
@Builder | |
public PersonTestData(Integer identificationNumber, | |
String name, | |
String email, | |
String phoneNumber, | |
String mobileNumber, | |
Address homeAddress, | |
Address officeAddress) { | |
super(identificationNumber, | |
name, | |
email, | |
phoneNumber, | |
mobileNumber, | |
homeAddress, | |
officeAddress); | |
} | |
public static PersonTestDataBuilder defaultBuilder() { | |
return PersonTestData | |
.builder() | |
.name("John") | |
.email("john@gmail.com") | |
.phoneNumber("888888") | |
.mobileNumber("888888"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment