use of com.orientechnologies.orient.test.domain.base.Satellite in project orientdb by orientechnologies.
the class ObjectTreeTest method childMapUpdateTest.
@Test(dependsOnMethods = "childNLevelUpdateTest")
public void childMapUpdateTest() {
OObjectDatabaseTx database = OObjectDatabasePool.global().acquire(url, "admin", "admin");
Planet p = database.newInstance(Planet.class);
p.setName("Earth");
p.setDistanceSun(1000);
Satellite sat = database.newInstance(Satellite.class);
sat.setDiameter(50);
sat.setName("Moon");
p.addSatelliteMap(sat);
database.save(p);
Assert.assertEquals(p.getDistanceSun(), 1000);
Assert.assertEquals(p.getName(), "Earth");
ORID rid = database.getIdentity(p);
database.close();
database = OObjectDatabasePool.global().acquire(url, "admin", "admin");
p = database.load(rid);
sat = p.getSatellitesMap().get("Moon");
Assert.assertEquals(p.getDistanceSun(), 1000);
Assert.assertEquals(p.getName(), "Earth");
Assert.assertEquals(sat.getDiameter(), 50);
sat.setDiameter(500);
database.save(p);
database.close();
database = OObjectDatabasePool.global().acquire(url, "admin", "admin");
p = database.load(rid);
sat = p.getSatellitesMap().get("Moon");
Assert.assertEquals(sat.getDiameter(), 500);
Assert.assertEquals(p.getDistanceSun(), 1000);
Assert.assertEquals(p.getName(), "Earth");
database.close();
}
use of com.orientechnologies.orient.test.domain.base.Satellite in project orientdb by orientechnologies.
the class ObjectTreeTestSchemaFull method childMapNLevelUpdateTest.
@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();
}
use of com.orientechnologies.orient.test.domain.base.Satellite in project orientdb by orientechnologies.
the class ObjectTreeTestSchemaFull method childMapUpdateTest.
@Test(dependsOnMethods = "childNLevelUpdateTest")
public void childMapUpdateTest() {
OObjectDatabaseTx database = OObjectDatabasePool.global().acquire(url, "admin", "admin");
Planet p = database.newInstance(Planet.class);
p.setName("Earth");
p.setDistanceSun(1000);
Satellite sat = database.newInstance(Satellite.class);
sat.setDiameter(50);
sat.setName("Moon");
p.addSatelliteMap(sat);
database.save(p);
Assert.assertEquals(p.getDistanceSun(), 1000);
Assert.assertEquals(p.getName(), "Earth");
ORID rid = database.getIdentity(p);
database.close();
database = OObjectDatabasePool.global().acquire(url, "admin", "admin");
p = database.load(rid);
sat = p.getSatellitesMap().get("Moon");
Assert.assertEquals(p.getDistanceSun(), 1000);
Assert.assertEquals(p.getName(), "Earth");
Assert.assertEquals(sat.getDiameter(), 50);
sat.setDiameter(500);
database.save(p);
database.close();
database = OObjectDatabasePool.global().acquire(url, "admin", "admin");
p = database.load(rid);
sat = p.getSatellitesMap().get("Moon");
Assert.assertEquals(sat.getDiameter(), 500);
Assert.assertEquals(p.getDistanceSun(), 1000);
Assert.assertEquals(p.getName(), "Earth");
database.close();
}
use of com.orientechnologies.orient.test.domain.base.Satellite in project orientdb by orientechnologies.
the class ObjectTreeTest method childUpdateTest.
@Test(dependsOnMethods = "testEnumListWithCustomTypes")
public void childUpdateTest() {
OObjectDatabaseTx database = OObjectDatabasePool.global().acquire(url, "admin", "admin");
Planet p = database.newInstance(Planet.class);
Satellite sat = database.newInstance(Satellite.class);
p.setName("Earth");
p.setDistanceSun(1000);
sat.setDiameter(50);
p.addSatellite(sat);
database.save(p);
ORID rid = database.getIdentity(p);
database.close();
database = OObjectDatabasePool.global().acquire(url, "admin", "admin");
p = database.load(rid);
sat = p.getSatellites().get(0);
Assert.assertEquals(sat.getDiameter(), 50);
Assert.assertEquals(p.getDistanceSun(), 1000);
Assert.assertEquals(p.getName(), "Earth");
sat.setDiameter(500);
// p.addSatellite(new Satellite("Moon", 70));
// db.save(sat);
database.save(p);
database.close();
database = OObjectDatabasePool.global().acquire(url, "admin", "admin");
p = database.load(rid);
sat = p.getSatellites().get(0);
Assert.assertEquals(sat.getDiameter(), 500);
Assert.assertEquals(p.getDistanceSun(), 1000);
Assert.assertEquals(p.getName(), "Earth");
database.close();
}
use of com.orientechnologies.orient.test.domain.base.Satellite in project orientdb by orientechnologies.
the class ObjectTreeTest method childMapNLevelUpdateTest.
@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();
}
Aggregations