C32DocumentDaoImpl implements C32DocumentDao { @Transactional public void insert(C32DocumentEntity document) { if (logger.isDebugEnabled()) { logger.debug("attempting persist for: " + document); } getEntityManager().persist(document); }  EntityManager getEntityManager(); void setEntityManager(EntityManager manager); @Transactional void insert(C32DocumentEntity document); @Transactional void update(C32DocumentEntity document); @SuppressWarnings("unchecked") @Transactional List<C32DocumentEntity> getAllDocuments(String patientId);  }
@Test public void insert() { java.util.Date now = new java.util.Date(); dao.insert(getNewC32Doc(now)); Assert.assertEquals(1, persistList.size()); C32DocumentEntity aDoc = (C32DocumentEntity)persistList.get(0); GregorianCalendar cal = new GregorianCalendar(); cal.setTime(now); assertDateEquals(aDoc.getCreateDate(), cal.get(GregorianCalendar.YEAR), cal.get(GregorianCalendar.MONTH), cal.get(GregorianCalendar.DAY_OF_MONTH), cal.get(GregorianCalendar.HOUR_OF_DAY), cal.get(GregorianCalendar.MINUTE), cal.get(GregorianCalendar.SECOND)); Assert.assertFalse(cal.get(GregorianCalendar.HOUR_OF_DAY)==0 && cal.get(GregorianCalendar.MINUTE)==0 && cal.get(GregorianCalendar.SECOND)==0); }
@Test public void insert_managerError() { java.util.Date now = new java.util.Date(); managerError = true; try { dao.insert(getNewC32Doc(now)); Assert.fail("error not thrown"); } catch (RuntimeException ex) {} }