@Test
public void testJPAAccessFactory() {
ODataJPAFactoryImpl oDataJPAFactoryImpl = new ODataJPAFactoryImpl();
JPAAccessFactory jpaAccessFactory = oDataJPAFactoryImpl.getJPAAccessFactory();
ODataJPAContextImpl oDataJPAContextImpl = new ODataJPAContextImpl();
Class<?> clazz = oDataJPAContextImpl.getClass();
try {
Field field = clazz.getDeclaredField("em");
field.setAccessible(true);
field.set(oDataJPAContextImpl, new JPAProcessorImplTest().getLocalEntityManager());
} catch (SecurityException e) {
fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
} catch (NoSuchFieldException e) {
fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
} catch (IllegalArgumentException e) {
fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
} catch (IllegalAccessException e) {
fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
}
EntityManagerFactory emf = new EntityManagerFactory() {
@Override
public boolean isOpen() {
return false;
}
@Override
public Map<String, Object> getProperties() {
return null;
}
@Override
public PersistenceUnitUtil getPersistenceUnitUtil() {
return null;
}
@Override
public Metamodel getMetamodel() {
return null;
}
@Override
public CriteriaBuilder getCriteriaBuilder() {
return null;
}
@Override
public Cache getCache() {
return null;
}
@SuppressWarnings("rawtypes")
@Override
public EntityManager createEntityManager(final Map arg0) {
return null;
}
@Override
public EntityManager createEntityManager() {
return null;
}
@Override
public void close() {}
};
oDataJPAContextImpl.setEntityManagerFactory(emf);
oDataJPAContextImpl.setPersistenceUnitName("pUnit");
assertNotNull(jpaAccessFactory.getJPAProcessor(oDataJPAContextImpl));
assertNotNull(jpaAccessFactory.getJPAEdmModelView(oDataJPAContextImpl));
}