database.close();
}
@Test(dependsOnMethods = "childMapUpdateTest")
public void childMapNLevelUpdateTest() {
OObjectDatabaseTx database = OObjectDatabasePool.global().acquire(url, "admin", "admin");
Planet jupiter = database.newInstance(Planet.class);
jupiter.setName("Jupiter");
jupiter.setDistanceSun(3000);
Planet mercury = database.newInstance(Planet.class);
mercury.setName("Mercury");
mercury.setDistanceSun(5000);
Satellite jupiterMoon = database.newInstance(Satellite.class);
Satellite mercuryMoon = database.newInstance(Satellite.class);
jupiterMoon.setDiameter(50);
jupiterMoon.setNear(mercury);
jupiterMoon.setName("JupiterMoon");
mercuryMoon.setDiameter(10);
mercuryMoon.setName("MercuryMoon");
mercury.addSatelliteMap(mercuryMoon);
jupiter.addSatelliteMap(jupiterMoon);
database.save(jupiter);
ORID rid = database.getIdentity(jupiter);
database.close();
database = OObjectDatabasePool.global().acquire(url, "admin", "admin");
jupiter = database.load(rid);
jupiterMoon = jupiter.getSatellitesMap().get("JupiterMoon");
mercury = jupiterMoon.getNear();
mercuryMoon = mercury.getSatellitesMap().get("MercuryMoon");
Assert.assertEquals(mercuryMoon.getDiameter(), 10);
Assert.assertEquals(mercuryMoon.getName(), "MercuryMoon");
Assert.assertEquals(jupiterMoon.getDiameter(), 50);
Assert.assertEquals(jupiterMoon.getName(), "JupiterMoon");
Assert.assertEquals(jupiter.getName(), "Jupiter");
Assert.assertEquals(jupiter.getDistanceSun(), 3000);
Assert.assertEquals(mercury.getName(), "Mercury");
Assert.assertEquals(mercury.getDistanceSun(), 5000);
mercuryMoon.setDiameter(100);
// p.addSatellite(new Satellite("Moon", 70));
// db.save(sat);
database.save(jupiter);
database.close();
database = OObjectDatabasePool.global().acquire(url, "admin", "admin");
jupiter = database.load(rid);
jupiterMoon = jupiter.getSatellitesMap().get("JupiterMoon");
mercury = jupiterMoon.getNear();
mercuryMoon = mercury.getSatellitesMap().get("MercuryMoon");
Assert.assertEquals(mercuryMoon.getDiameter(), 100);
Assert.assertEquals(mercuryMoon.getName(), "MercuryMoon");
Assert.assertEquals(jupiterMoon.getDiameter(), 50);
Assert.assertEquals(jupiterMoon.getName(), "JupiterMoon");
Assert.assertEquals(jupiter.getName(), "Jupiter");
Assert.assertEquals(jupiter.getDistanceSun(), 3000);
Assert.assertEquals(mercury.getName(), "Mercury");
Assert.assertEquals(mercury.getDistanceSun(), 5000);
database.close();
}