@Test
public void testFindAll() throws Exception {

  DynamicClassLoader classLoader = new DynamicClassLoader(DataStoreImplTest.class.getClassLoader());
  // create mocks
  JpaEntityManager jpaEntityManager = createMock(JpaEntityManager.class);
  ServerSession session = createMock(ServerSession.class);
  DatabaseLogin databaseLogin = createMock(DatabaseLogin.class);
  EntityManagerFactory entityManagerFactory = createMock(EntityManagerFactory.class);
  EntityManager entityManager = createMock(EntityManager.class);
  JPADynamicHelper jpaDynamicHelper = createNiceMock(JPADynamicHelper.class);
  SchemaManager schemaManager = createNiceMock(SchemaManager.class);
  DynamicEntity dynamicEntity = createMock(DynamicEntity.class);
  Query query = createMock(Query.class);
  // set expectations
  PowerMock.mockStatic(JpaHelper.class);
  expect(JpaHelper.getEntityManager(entityManager)).andReturn(jpaEntityManager).anyTimes();
  PowerMock.replay(JpaHelper.class);
  expect(jpaEntityManager.getServerSession()).andReturn(session).anyTimes();
  expect(session.getLogin()).andReturn(databaseLogin).anyTimes();
  Capture<Sequence> sequenceCapture = EasyMock.newCapture();
  databaseLogin.addSequence(capture(sequenceCapture));
  EasyMock.expectLastCall().anyTimes();
  Capture<DynamicType> typeCapture = EasyMock.newCapture();
  Capture<DynamicType> typeCapture2 = EasyMock.newCapture();
  jpaDynamicHelper.addTypes(eq(true), eq(true), capture(typeCapture), capture(typeCapture2));
  expect(entityManagerFactory.createEntityManager()).andReturn(entityManager).anyTimes();
  expect(entityManager.createQuery(
      "SELECT e FROM DS_DataStoreImplTest$TestEntity_1 e WHERE e.DS_id=99")).andReturn(query);
  entityManager.close();
  expect(query.getResultList()).andReturn(Collections.singletonList(dynamicEntity));
  expect(dynamicEntity.get("DS_id")).andReturn(99);
  expect(dynamicEntity.get("DS_name")).andReturn("foo");
  TestSubEntity subEntity = new TestSubEntity("bar");
  expect(dynamicEntity.get("DS_subEntity")).andReturn(subEntity);
  // replay mocks
  replay(entityManagerFactory, entityManager, jpaDynamicHelper, dynamicEntity, query, schemaManager, jpaEntityManager, session, databaseLogin);
  DataStoreImpl dataStore = getDataStore(entityManagerFactory, jpaDynamicHelper, classLoader, schemaManager);
  Collection<TestEntity> entities = dataStore.findAll(TestEntity.class, "id=99");
  Assert.assertEquals(1, entities.size());
  TestEntity entity = entities.iterator().next();
  Assert.assertEquals(99, (int) entity.getId());
  Assert.assertEquals("foo", entity.getName());
  // verify mocks
  verify(entityManagerFactory, entityManager, jpaDynamicHelper, dynamicEntity, query, schemaManager, jpaEntityManager, session, databaseLogin);
}