@Test(expected = HibernateException.class) public void testDeleteDataKO() { // Setup Person input = new Person(); doThrow(new HibernateException("")).when(session).delete(input); // Action dao.deletePerson(input); }
@Test public void testDeleteDataOK() { // Setup Person input = new Person(); // Action dao.deletePerson(input); // Test verify(factory, times(1)).getCurrentSession(); verify(session, times(1)).delete(input); }