use of com.orientechnologies.orient.test.domain.business.Country in project orientdb by orientechnologies.
the class ObjectTreeTest method testPersonSaving.
@Test
public void testPersonSaving() {
final long beginProfiles = database.countClass("Profile");
beginCities = database.countClass("City");
Country italy = database.newInstance(Country.class, "Italy");
Profile garibaldi = database.newInstance(Profile.class, "GGaribaldi", "Giuseppe", "Garibaldi", null);
garibaldi.setLocation(database.newInstance(Address.class, "Residence", database.newInstance(City.class, italy, "Rome"), "Piazza Navona, 1"));
Profile bonaparte = database.newInstance(Profile.class, "NBonaparte", "Napoleone", "Bonaparte", garibaldi);
bonaparte.setLocation(database.newInstance(Address.class, "Residence", garibaldi.getLocation().getCity(), "Piazza di Spagna, 111"));
database.save(bonaparte);
Assert.assertEquals(database.countClass("Profile"), beginProfiles + 2);
}
use of com.orientechnologies.orient.test.domain.business.Country in project orientdb by orientechnologies.
the class ObjectDetachingTest method testOrientObjectIdPlusVersionAnnotationsNotInTx.
@SuppressWarnings("unchecked")
@Test(dependsOnMethods = "testOrientStringIdAnnotation")
public void testOrientObjectIdPlusVersionAnnotationsNotInTx() {
// BROWSE ALL THE OBJECTS
Assert.assertTrue(database.countClass(Country.class) > 0);
for (Country c : (List<Country>) database.query(new OSQLSynchQuery<Object>("select from Country where name = 'Austria'"))) {
Assert.assertNotNull(c.getId());
Assert.assertNotNull(c.getVersion());
// UPDATE IT TO GET NEWER VERSION
c.setName(c.getName() + " v1");
database.save(c);
// CHECK VERSION
Assert.assertTrue((Integer) c.getVersion() > 0);
}
// BROWSE ALL THE OBJECTS
for (Country c : (List<Country>) database.query(new OSQLSynchQuery<Object>("select from Country where name = 'Austria v1'"))) {
Assert.assertNotNull(c.getId());
Assert.assertNotNull(c.getVersion());
Assert.assertTrue((Integer) c.getVersion() > 0);
}
}
use of com.orientechnologies.orient.test.domain.business.Country in project orientdb by orientechnologies.
the class ObjectDetachingTestSchemaFull method testOrientObjectIdPlusVersionAnnotationsNotInTx.
@SuppressWarnings("unchecked")
@Test(dependsOnMethods = "testOrientStringIdAnnotation")
public void testOrientObjectIdPlusVersionAnnotationsNotInTx() {
// DELETE PREVIOUS TESTS DATA
database.command(new OCommandSQL("delete from Country where name = 'Austria v1'")).execute();
// BROWSE ALL THE OBJECTS
Assert.assertTrue(database.countClass(Country.class) > 0);
for (Country c : (List<Country>) database.query(new OSQLSynchQuery<Object>("select from Country where name = 'Austria'"))) {
Assert.assertNotNull(c.getId());
Assert.assertNotNull(c.getVersion());
// UPDATE IT TO GET NEWER VERSION
c.setName(c.getName() + " v1");
database.save(c);
// CHECK VERSION
Assert.assertTrue(((Integer) c.getVersion()) > 0);
}
// BROWSE ALL THE OBJECTS
for (Country c : (List<Country>) database.query(new OSQLSynchQuery<Object>("select from Country where name = 'Austria v1'"))) {
Assert.assertNotNull(c.getId());
Assert.assertNotNull(c.getVersion());
Assert.assertTrue(((Integer) c.getVersion()) > 0);
}
}
use of com.orientechnologies.orient.test.domain.business.Country in project orientdb by orientechnologies.
the class ObjectDetachingTestSchemaFull method testDeleteRollback.
@Test(dependsOnMethods = "testDeleteCommit")
public void testDeleteRollback() {
String initialCountryName = "deleteRollback";
Country country = new Country(initialCountryName);
long initCount = database.countClass(Country.class);
country = database.save(country);
Assert.assertEquals(database.countClass(Country.class), initCount + 1);
database.begin();
database.delete(country);
database.rollback();
Assert.assertEquals(database.countClass(Country.class), initCount + 1);
Country found = database.load((ORecordId) country.getId());
Assert.assertNotNull(found);
Assert.assertEquals(found.getName(), country.getName());
}
use of com.orientechnologies.orient.test.domain.business.Country in project orientdb by orientechnologies.
the class CRUDObjectPhysicalTestSchemaFull method update.
@Test(dependsOnMethods = "mapEnumAndInternalObjects")
public void update() {
int i = 0;
Account a;
for (Object o : database.browseCluster("Account").setFetchPlan("*:1")) {
a = (Account) o;
if (i % 2 == 0)
a.getAddresses().set(0, new Address("work", new City(new Country("Spain"), "Madrid"), "Plaza central"));
a.setSalary(i + 500.10f);
database.save(a);
i++;
}
}
Aggregations