}
@Test(dependsOnMethods = "createSchema")
public void lazySimple() throws Exception {
PersistenceSession session = persistenceManager.createSession();
try {
LazySimpleEntity inst = new LazySimpleEntity();
inst.setId(1);
inst.setStrList(Arrays.asList("one", "two", "three"));
inst.setLazyStrList(Arrays.asList("one", "two", "three"));
inst.setStrSet(new HashSet<String>(inst.getStrList()));
inst.setLazyStrSet(new HashSet<String>(inst.getStrList()));
inst.getStrMap().put("one", "1");
inst.getStrMap().put("two", "2");
inst.getStrMap().put("three", "3");
inst.getLazyStrMap().put("one", "1");
inst.getLazyStrMap().put("two", "2");
inst.getLazyStrMap().put("three", "3");
session.insert(inst);
LazySimpleEntity loaded = session.loadOneWithOptions(LazySimpleEntity.class, PersistOption.single(PersistOption.loadEager()), 1);
Assert.assertNotNull(loaded);
Assert.assertEquals(loaded.getId(), 1);
Assert.assertNotNull(loaded.getStrList());
Assert.assertNotNull(loaded.getStrSet());
Assert.assertNotNull(loaded.getStrMap());
Assert.assertNotNull(loaded.getLazyStrList());
Assert.assertNotNull(loaded.getLazyStrSet());
Assert.assertNotNull(loaded.getLazyStrMap());
Assert.assertTrue(loaded.getStrList() instanceof ArrayList);
Assert.assertTrue(loaded.getStrSet() instanceof HashSet);
Assert.assertTrue(loaded.getStrMap() instanceof HashMap);
Assert.assertFalse(loaded.getLazyStrList() instanceof LazyList);
Assert.assertFalse(loaded.getLazyStrSet() instanceof LazySet);
Assert.assertFalse(loaded.getLazyStrMap() instanceof LazyMap);
Assert.assertEquals(loaded.getStrList(), Arrays.asList("one", "two", "three"));
Assert.assertEquals(loaded.getLazyStrList(), Arrays.asList("one", "two", "three"));
Assert.assertEquals(loaded.getStrSet(), new HashSet<String>(Arrays.asList("one", "two", "three")));
Assert.assertEquals(loaded.getLazyStrSet(), new HashSet<String>(Arrays.asList("one", "two", "three")));
Assert.assertEquals(loaded.getStrMap().keySet(), new HashSet<String>(Arrays.asList("one", "two", "three")));
Assert.assertEquals(loaded.getLazyStrMap().keySet(), new HashSet<String>(Arrays.asList("one", "two", "three")));
loaded = session.loadOne(LazySimpleEntity.class, 1);
session.update(loaded);
Assert.assertNotNull(loaded);
Assert.assertEquals(loaded.getId(), 1);
Assert.assertNotNull(loaded.getStrList());
Assert.assertNotNull(loaded.getStrSet());
Assert.assertNotNull(loaded.getStrMap());
Assert.assertNotNull(loaded.getLazyStrList());
Assert.assertNotNull(loaded.getLazyStrSet());
Assert.assertNotNull(loaded.getLazyStrMap());
Assert.assertTrue(loaded.getStrList() instanceof ArrayList);
Assert.assertTrue(loaded.getStrSet() instanceof HashSet);
Assert.assertTrue(loaded.getStrMap() instanceof HashMap);
Assert.assertTrue(loaded.getLazyStrList() instanceof LazyList);
Assert.assertTrue(loaded.getLazyStrSet() instanceof LazySet);
Assert.assertTrue(loaded.getLazyStrMap() instanceof LazyMap);
Assert.assertFalse(((AbstractLazy) loaded.getLazyStrList()).isLoaded());
Assert.assertFalse(((AbstractLazy) loaded.getLazyStrSet()).isLoaded());
Assert.assertFalse(((AbstractLazy) loaded.getLazyStrMap()).isLoaded());
Assert.assertEquals(loaded.getStrList(), Arrays.asList("one", "two", "three"));
Assert.assertEquals(loaded.getLazyStrList(), Arrays.asList("one", "two", "three"));
Assert.assertEquals(loaded.getStrSet(), new HashSet<String>(Arrays.asList("one", "two", "three")));
Assert.assertEquals(loaded.getLazyStrSet(), new HashSet<String>(Arrays.asList("one", "two", "three")));
Assert.assertEquals(loaded.getStrMap().keySet(), new HashSet<String>(Arrays.asList("one", "two", "three")));
Assert.assertEquals(loaded.getLazyStrMap().keySet(), new HashSet<String>(Arrays.asList("one", "two", "three")));
Assert.assertFalse(loaded.getLazyStrList() instanceof LazyList);
Assert.assertFalse(loaded.getLazyStrSet() instanceof LazySet);
Assert.assertFalse(loaded.getLazyStrMap() instanceof LazyMap);
loaded = session.loadOne(LazySimpleEntity.class, 1);
Assert.assertNotNull(loaded);
Assert.assertEquals(loaded.getId(), 1);
Assert.assertNotNull(loaded.getStrList());
Assert.assertNotNull(loaded.getStrSet());
Assert.assertNotNull(loaded.getStrMap());
Assert.assertNotNull(loaded.getLazyStrList());
Assert.assertNotNull(loaded.getLazyStrSet());
Assert.assertNotNull(loaded.getLazyStrMap());
Assert.assertTrue(loaded.getStrList() instanceof ArrayList);
Assert.assertTrue(loaded.getStrSet() instanceof HashSet);
Assert.assertTrue(loaded.getStrMap() instanceof HashMap);
Assert.assertTrue(loaded.getLazyStrList() instanceof LazyList);
Assert.assertTrue(loaded.getLazyStrSet() instanceof LazySet);
Assert.assertTrue(loaded.getLazyStrMap() instanceof LazyMap);
Assert.assertFalse(((AbstractLazy) loaded.getLazyStrList()).isLoaded());
Assert.assertFalse(((AbstractLazy) loaded.getLazyStrSet()).isLoaded());
Assert.assertFalse(((AbstractLazy) loaded.getLazyStrMap()).isLoaded());
session.loadLazy(loaded);
Assert.assertFalse(loaded.getLazyStrList() instanceof LazyList);
Assert.assertFalse(loaded.getLazyStrSet() instanceof LazySet);
Assert.assertFalse(loaded.getLazyStrMap() instanceof LazyMap);
Assert.assertEquals(loaded.getStrList(), Arrays.asList("one", "two", "three"));
Assert.assertEquals(loaded.getLazyStrList(), Arrays.asList("one", "two", "three"));
Assert.assertEquals(loaded.getStrSet(), new HashSet<String>(Arrays.asList("one", "two", "three")));
Assert.assertEquals(loaded.getLazyStrSet(), new HashSet<String>(Arrays.asList("one", "two", "three")));
Assert.assertEquals(loaded.getStrMap().keySet(), new HashSet<String>(Arrays.asList("one", "two", "three")));
Assert.assertEquals(loaded.getLazyStrMap().keySet(), new HashSet<String>(Arrays.asList("one", "two", "three")));
}finally {session.close();}
}