em.persist(p3);
col.put("1", p1);
col.put("2", p2);
col.put("3", p3);
em.clear();
PersonMongo p = findById(PersonMongo.class, "1", em);
Assert.assertNotNull(p);
Assert.assertEquals(Day.FRIDAY, p.getDay());
Assert.assertEquals(Month.JAN, p.getMonth());
Assert.assertEquals("vivek", p.getPersonName());
Assert.assertNotNull(p.getMap());
Assert.assertFalse(p.getMap().isEmpty());
Assert.assertEquals(2, p.getMap().size());
assertFindByName(em, "PersonMongo", PersonMongo.class, "vivek", "personName");
assertFindByNameAndAge(em, "PersonMongo", PersonMongo.class, "vivek", "10", "personName");
assertFindByNameAndAgeGTAndLT(em, "PersonMongo", PersonMongo.class, "vivek", "10", "20", "personName");
assertFindByNameAndAgeBetween(em, "PersonMongo", PersonMongo.class, "vivek", "10", "15", "personName");
assertFindByRange(em, "PersonMongo", PersonMongo.class, "1", "2", "personId");
assertFindWithoutWhereClause(em, "PersonMongo", PersonMongo.class);
Query query = em.createNamedQuery("mongo.named.query");
query.setParameter("name", "vivek");
List<PersonMongo> results = query.getResultList();
Assert.assertEquals(3, results.size());
Assert.assertEquals(Month.JAN, results.get(0).getMonth());
query = em.createNamedQuery("mongo.position.query");
query.setParameter(1, "vivek");
results = query.getResultList();
Assert.assertEquals(3, results.size());
Assert.assertEquals(Month.JAN, results.get(0).getMonth());
findQuery = em.createQuery("Select p from PersonMongo p where p.day = :day");
findQuery.setParameter("day", Day.FRIDAY);
allPersons = findQuery.getResultList();
Assert.assertNotNull(allPersons);
Assert.assertEquals(3, allPersons.size());
query = em.createQuery("select p from PersonMongo p");
query.setMaxResults(2);
results = query.getResultList();
Assert.assertNotNull(results);
Assert.assertEquals(2, results.size());
Assert.assertEquals(Month.JAN, results.get(0).getMonth());
query = em.createQuery("select p from PersonMongo p");
query.setMaxResults(1);
PersonMongo result = (PersonMongo)(query.getSingleResult());
Assert.assertNotNull(result);
Assert.assertEquals(Month.JAN, result.getMonth());
query = em.createQuery("select p from PersonMongo p where p.personName = kuldeep");
try
{
result = (PersonMongo)(query.getSingleResult());