@@ -0,0 +1,1563 @@
+package com.enginemobi.core.generic.util;%0A%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.orm.jpa.EntityManagerFactoryUtils;%0Aimport org.springframework.orm.jpa.EntityManagerHolder;%0Aimport org.springframework.stereotype.Component;%0Aimport org.springframework.transaction.support.TransactionSynchronizationManager;%0A%0Aimport javax.persistence.EntityManager;%0Aimport javax.persistence.EntityManagerFactory;%0Aimport javax.persistence.PersistenceContext;%0A%0A@Component%0Apublic class EntityManagerUtils %7B%0A%09%0A%09@Autowired%0A%09private EntityManagerFactory entityManagerFactory;%0A%09%0A%09@PersistenceContext%0A%09private EntityManager entityManager;%0A%09%0A%09public EntityManager openEntityManager() %7B%0A%09%09if (TransactionSynchronizationManager.hasResource(entityManagerFactory)) %7B%0A%09%09%09return ((EntityManagerHolder) TransactionSynchronizationManager.getResource(entityManagerFactory)).getEntityManager();%0A%09%09%7D else %7B%0A%09%09%09EntityManager entityManager = entityManagerFactory.createEntityManager();%0A%09%09%09TransactionSynchronizationManager.bindResource(entityManagerFactory, new EntityManagerHolder(entityManager));%0A%09%09%09return entityManager;%0A%09%09%7D%0A%09%7D%0A%09%0A%09public void closeEntityManager() %7B%0A%09%09if (TransactionSynchronizationManager.hasResource(entityManagerFactory)) %7B%0A%09%09%09EntityManagerHolder entityManagerHolder = (EntityManagerHolder) TransactionSynchronizationManager.unbindResource(entityManagerFactory);%0A%09%09%09EntityManagerFactoryUtils.closeEntityManager(entityManagerHolder.getEntityManager());%0A%09%09%7D%0A%09%7D%0A%09%0A%09public EntityManager getEntityManager() %7B%0A%09%09return entityManager;%0A%09%7D%0A%7D%0A

Add entity manager utils for unit testing