DynamicClassLoader classLoader = new DynamicClassLoader(DataStoreImplTest.class.getClassLoader());
// create mocks
EntityManagerFactory entityManagerFactory = createMock(EntityManagerFactory.class);
EntityManager entityManager = createMock(EntityManager.class);
JPADynamicHelper jpaDynamicHelper = createNiceMock(JPADynamicHelper.class);
SchemaManager schemaManager = createNiceMock(SchemaManager.class);
DynamicEntity dynamicEntity1 = createMock(DynamicEntity.class);
DynamicEntity dynamicEntity2 = createMock(DynamicEntity.class);
DynamicEntity dynamicEntity3 = createMock(DynamicEntity.class);
Query query = createMock(Query.class);
// set expectations
Capture<DynamicType> typeCapture = new Capture<DynamicType>();
jpaDynamicHelper.addTypes(eq(true), eq(true), capture(typeCapture));
expect(entityManagerFactory.createEntityManager()).andReturn(entityManager);
expect(entityManager.createQuery(
"SELECT e FROM DataStoreImplTest$TestEntity1 e WHERE e.name='foo'")).andReturn(query);
entityManager.close();