EntityManagerImpl implements AbstractEntityManager, Wrapper { @Override public boolean contains(Object entity) { try { ensureOpen(); Objects.requireNonNull(entity); checkClassIsValidEntity(entity.getClass()); return getCurrentPersistenceContext().contains(entity); } catch (RuntimeException e) { markTransactionForRollback(); throw e; } } EntityManagerImpl(EntityManagerFactoryImpl emf, Configuration configuration, ServerSession serverSession); @Override void persist(final Object entity); @Override void persist(final Object entity, final Descriptor descriptor); @Override T merge(final T entity); @Override T merge(final T entity, final Descriptor descriptor); @Override void remove(Object object); @Override T find(Class<T> cls, Object identifier); @Override T find(Class<T> cls, Object identifier, Descriptor descriptor); @Override T getReference(Class<T> entityClass, Object identifier); @Override T getReference(Class<T> entityClass, Object identifier, Descriptor descriptor); @Override void flush(); @Override void refresh(Object entity); @Override void clear(); @Override void detach(Object entity); @Override boolean contains(Object entity); @Override void close(); @Override boolean isOpen(); @Override EntityTransaction getTransaction(); @Override EntityManagerFactoryImpl getEntityManagerFactory(); @Override Metamodel getMetamodel(); @Override boolean isLoaded(final Object object, final String attributeName); @Override boolean isLoaded(Object object); @Override QueryImpl createQuery(String qlString); @Override TypedQueryImpl<T> createQuery(String query, Class<T> resultClass); @Override QueryImpl createNativeQuery(String sparqlString); @Override TypedQueryImpl<T> createNativeQuery(String sparqlString, Class<T> resultClass); @Override QueryImpl createNativeQuery(String sparqlString, String resultSetMapping); @Override QueryImpl createNamedQuery(String name); @Override TypedQueryImpl<T> createNamedQuery(String name, Class<T> resultClass); @Override boolean isConsistent(URI context); @Override List<URI> getContexts(); @Override void setUseTransactionalOntologyForQueryProcessing(); @Override boolean useTransactionalOntologyForQueryProcessing(); @Override void setUseBackupOntologyForQueryProcessing(); @Override boolean useBackupOntologyForQueryProcessing(); @Override T unwrap(Class<T> cls); @Override Object getDelegate(); @Override UnitOfWorkImpl getCurrentPersistenceContext(); @Override void removeCurrentPersistenceContext(); @Override void transactionStarted(EntityTransaction t); @Override void transactionFinished(EntityTransaction t); @Override Configuration getConfiguration();  }
@Test void containsThrowsIllegalArgumentForNonEntity() { final UnknownEntity obj = new UnknownEntity(); final IllegalArgumentException ex = assertThrows(IllegalArgumentException.class, () -> em.contains(obj)); assertEquals(NON_ENTITY_CLASS_EXCEPTION_MESSAGE, ex.getMessage()); }