### Question:
PersistenceDelegator { public void persist(Object e) { if (e == null) { throw new IllegalArgumentException( "Entity object is invalid, operation failed. Please check previous log message for details"); } ObjectGraph graph = new GraphGenerator().generateGraph(e, this); Node node = graph.getHeadNode(); try { lock.writeLock().lock(); node.setPersistenceDelegator(this); node.persist(); flushManager.buildFlushStack(node, com.impetus.kundera.persistence.context.EventLog.EventType.INSERT); flush(); getPersistenceCache().getMainCache().addHeadNode(node); } finally { lock.writeLock().unlock(); } graph.clear(); graph = null; if (log.isDebugEnabled()) { log.debug("Data persisted successfully for entity {}.", e.getClass()); } } PersistenceDelegator(final KunderaMetadata kunderaMetadata, final PersistenceCache pc); void persist(Object e); E findById(final Class<E> entityClass, final Object primaryKey); List<E> find(Class<E> entityClass, Object... primaryKeys); List<E> find(Class<E> entityClass, Map<String, String> embeddedColumnMap); void remove(Object e); E merge(E e); void detach(Object entity); Client getClient(EntityMetadata m); Client getClient(final String persistenceUnit); EntityEventDispatcher getEventDispatcher(); boolean isOpen(); void refresh(Object entity); boolean isTransactionInProgress(); PersistenceCache getPersistenceCache(); KunderaMetadata getKunderaMetadata();  }### Answer:
@Test public void testPersist() { try { em.persist(null); Assert.fail("A null entity should have thrown exception while persisting"); } catch (Exception e1) { Assert.assertTrue(e1.getCause().getClass().equals(IllegalArgumentException.class)); } PersonnelDTO dto = new PersonnelDTO(); try { em.persist(dto); } catch (KunderaException e) { Assert.assertEquals( "java.lang.IllegalArgumentException: Entity to be persisted can't have Primary key set to null.", e.getMessage()); } try { CoreEntityAddressUni1To1 Oneto1 = new CoreEntityAddressUni1To1(); em.persist(Oneto1); } catch (KunderaException e) { Assert.assertNotNull(e.getMessage()); } em.clear(); dto = new PersonnelDTO(); dto.setPersonId("123"); em.persist(dto); dto = em.find(PersonnelDTO.class, "123"); Assert.assertNotNull(dto); Assert.assertEquals("123", dto.getPersonId()); }