Set<AddressB1M> addressess = new HashSet<AddressB1M>();
addressess.add(address1);
addressess.add(address2);
PersonB1M p1 = new PersonB1M();
p1.setPersonName("vivek");
p1.setPersonId("1");
p1.setAddresses(addressess);
em.persist(p1);
PersistenceDelegator delegator = CoreTestUtilities.getDelegator(em);
Map<String, Object> relationMap = null;
EntityMetadata metadata = KunderaMetadataManager.getEntityMetadata(
((EntityManagerFactoryImpl) emf).getKunderaMetadataInstance(), PersonB1M.class);
CoreTestEntityReader reader = new CoreTestEntityReader(kunderaMetadata);
p1.setAddresses(null);
reader.recursivelyFindEntities(p1, relationMap, metadata, delegator, false);
Assert.assertNotNull(p1.getAddresses());
Assert.assertTrue(ProxyHelper.isKunderaProxyCollection(p1.getAddresses()));
// Assert.assertEquals(p1,
// p1.getAddresses().iterator().next().getPerson());
// Assert.assertEquals(p1,
// p1.getAddresses().iterator().next().getPerson());
p1.setAddresses(null);
reader.recursivelyFindEntities(p1, relationMap, metadata, delegator, true);
Assert.assertNotNull(p1.getAddresses());
Assert.assertFalse(ProxyHelper.isKunderaProxyCollection(p1.getAddresses()));
// Assert.assertEquals(p1,
// p1.getAddresses().iterator().next().getPerson());
// Assert.assertEquals(p1,
// p1.getAddresses().iterator().next().getPerson());