@Test public void shouldCreateAddressBookWithANewContact() { AddressBookBuilder addressBookbuilder = AddressBookBuilder.getAddressBookBuilder(); ContactBuilder contactBuilder = ContactBuilder.getContactBuilder(); Contact contact1 = contactBuilder.withName("Will").withNumber("0199999999").withNumber("0299999999").build(); AddressBook book = addressBookbuilder.withName("Book 1").withContact(contact1).build(); assertNotNull(book); assertEquals(1, book.getContacts().size()); Contact contact2 = contactBuilder.withName("Bill").withNumber("0399999999").withNumber("0499999999").build(); Set<Contact> contactSet = new HashSet<Contact>(); contactSet.add(contact2); book = addressBookbuilder.withName("Book 1").withNewContactSet(contactSet).build(); assertNotNull(book); assertEquals(1, book.getContacts().size()); }
@Test public void shouldCreateAddressBookWithContact() { AddressBookBuilder addressBookbuilder = AddressBookBuilder.getAddressBookBuilder(); ContactBuilder contactBuilder = ContactBuilder.getContactBuilder(); Contact contact1 = contactBuilder.withName("Will").withNumber("0199999999").withNumber("0299999999").build(); AddressBook book = addressBookbuilder.withName("Book 1").withContact(contact1).build(); assertNotNull(book); assertEquals(1, book.getContacts().size()); Contact contact2 = contactBuilder.withName("Boby").withNumber("0199999999").withNumber("0299999999").build(); book = addressBookbuilder.withContact(contact2).build(); assertNotNull(book); assertEquals(2, book.getContacts().size()); }