mgr.fillInWithKey(sub);
mgr.put(user);
mgr.flush();
NoSqlEntityManager mgr2 = factory.createEntityManager();
User user2 = mgr2.find(User.class, user.getId());
//Check single entity
EmbeddedEmail emailSub = user2.getEmail();
Assert.assertNotNull(emailSub);
Assert.assertEquals(sub.getIdkey(), emailSub.getIdkey());
Assert.assertEquals(sub.getName(), emailSub.getName());
//Check List of entities
List<EmbeddedEmail> emails = user2.getEmails();
Assert.assertEquals(3, emails.size());
EmbeddedEmail email = emails.get(0);
Assert.assertNotNull(email);
Assert.assertEquals(e1.getIdkey(), email.getIdkey());
Assert.assertEquals(e1.getName(), email.getName());
EmbeddedEmail email2 = emails.get(1);
Assert.assertEquals(e2.getName(), email2.getName());
// check if deleting embedded stuff is working fine
NoSqlEntityManager mgr3 = factory.createEntityManager();
user2.getEmails().remove(0);
mgr3.put(user2);
mgr3.flush();
NoSqlEntityManager mgr4 = factory.createEntityManager();
User user3 = mgr4.find(User.class, user2.getId());
List<EmbeddedEmail> emails2 = user3.getEmails();
Assert.assertEquals(2, emails2.size());
// check if delete is working by passing object
NoSqlEntityManager mgr5 = factory.createEntityManager();
User user4 = mgr5.find(User.class, user.getId());
user4.getEmails().remove(e3);
mgr5.put(user4);
mgr5.flush();
NoSqlEntityManager mgr6 = factory.createEntityManager();
User user5 = mgr6.find(User.class, user.getId());
List<EmbeddedEmail> emails4 = user5.getEmails();
Assert.assertEquals(1, emails4.size());
// To check if delete is working fine
mgr.remove(user2);