EntityManagerFactoryImpl implements EntityManagerFactory, PersistenceUnitUtil { @Override public <T> T unwrap(Class<T> cls) { ensureOpen(); if (cls.isAssignableFrom(this.getClass())) { return cls.cast(this); } return serverSession.unwrap(cls); } EntityManagerFactoryImpl(final Map<String, String> properties); @Override void close(); @Override EntityManager createEntityManager(); @Override EntityManager createEntityManager(Map<String, String> map); ServerSession getServerSession(); @Override boolean isOpen(); @Override Map<String, String> getProperties(); @Override Metamodel getMetamodel(); @Override PersistenceUnitUtil getPersistenceUnitUtil(); @Override void addNamedQuery(String name, Query query); @Override T unwrap(Class<T> cls); @Override Object getIdentifier(Object entity); @Override boolean isLoaded(Object entity, String attributeName); @Override boolean isLoaded(Object entity); @Override Cache getCache();  }
@Test void unwrapReturnsReturnsEntityManagerFactoryImplWhenTypeMatches() { final EntityManagerFactoryImpl result = emf.unwrap(EntityManagerFactoryImpl.class); assertNotNull(result); assertSame(emf, result); }