@Test public void testInsertWithDetail() { LOG.info("Insert contact with details"); ContactTelDetail contactTelDetail1 = new ContactTelDetail(); contactTelDetail1.setTelType(telType1); contactTelDetail1.setTelNumЬer(telNumЬer1); ContactTelDetail contactTelDetail2 = new ContactTelDetail(); contactTelDetail2.setTelType(telType2); contactTelDetail2.setTelNumЬer(telNumЬer2); List<ContactTelDetail> contactTelDetailList = new ArrayList<ContactTelDetail>(); contactTelDetailList.add(contactTelDetail1); contactTelDetailList.add(contactTelDetail2); Contact contact2 = new Contact(); contact2.setFirstName(firstName3); contact2.setLastName(lastName3); contact2.setBirthDate(birthDate3); contact2.setContactTelDetails(contactTelDetailList); LOG.info("Insert contact with details :" + contact2); contactDao.insertWithDetail(contact2); List<Contact> contactList = contactDao.findByFirstName(firstName3); Assert.assertEquals(firstName3, contactList.get(0).getFirstName()); Assert.assertEquals(lastName3, contactList.get(0).getLastName()); }
@Test public void testInsert() { LOG.info("Insert contact"); Contact contact = new Contact(); contact.setFirstName(firstNameExpected2); contact.setLastName(lastNameExpected2); contact.setBirthDate(birthDateExpected2); LOG.info("Insert contact" + contact); contactDao.insert(contact); List<Contact> contactList = contactDao.findByFirstName(firstNameExpected2); Assert.assertEquals(firstNameExpected2, contactList.get(0).getFirstName()); Assert.assertEquals(lastNameExpected2, contactList.get(0).getLastName()); }
@Test public void testUpdate() { // insert new contact and update Contact contact = new Contact(); contact.setFirstName(firstNameIns); contact.setLastName(lastNameIns); contact.setBirthDate(birthDateIns); LOG.info("Insert new contact " + contact); contactDao.insert(contact); List<Contact> contactlist = contactDao.findByFirstName(firstNameIns); Contact contactForUpdate = contactlist.get(0); LOG.info("Update new contact"); Contact contactUpdate = new Contact(); contactUpdate.setId(contactForUpdate.getId()); contactUpdate.setFirstName(firstNameUpdate); contactUpdate.setLastName(lastNameUpdate); contactUpdate.setBirthDate(birthDateUpdate); contactDao.update(contactUpdate); String firstNameUpdateById = contactDao.findFirstNameById(contactForUpdate.getId()); Assert.assertEquals(firstNameUpdate, firstNameUpdateById); }