We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When using example and getDefault call another factory, can cause duplicated data.
getDefault
Example:
@Data public class Phone { private String number; private Contact contact; } @Data public class Contact { private String name; } @Component public class ContactFactory extends JBacon<Contact> { @Autowired private ContactRepository contactRepository; @Override public Contact getDefault() { Contact contact = new Contact(); contact.setName("teste"); return contact; } @Override public Contact getEmpty() { return new Contact(); } @Override public void persist(Contact contact) { contactRepository.save(contact); } } @Component public class PhoneFactory extends JBacon<Contact> { @Autowired private PhoneRepository phoneRepository; @Autowired private ContactFactory contactFactory; @Override public Phone getDefault() { Phone phone = new Phone(); phone.setNumber("16 99999-9999"); phone.setContact(contactFactory.create()); return phone; } @Override public Phone getEmpty() { return new Phone(); } @Override public void persist(Phone phone) { phoneRepository.save(phone); } }
In tests:
Contact contact = contactFactory.create(empty -> { empty.setName("Leonardo"); }); phoneFactory.create(5, empty -> { empty.setContact(contact); });
6 Contacts will be persisted in database.
The text was updated successfully, but these errors were encountered:
#11
Sorry, something went wrong.
No branches or pull requests
When using example and
getDefault
call another factory, can cause duplicated data.Example:
In tests:
6 Contacts will be persisted in database.
The text was updated successfully, but these errors were encountered: