Search in sources :

Example 1 with Country

use of com.orientechnologies.orient.test.domain.business.Country in project orientdb by orientechnologies.

the class ObjectTreeTestSchemaFull 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);
    Assert.assertEquals(database.countClass("City"), beginCities + 1);
}
Also used : Address(com.orientechnologies.orient.test.domain.business.Address) Country(com.orientechnologies.orient.test.domain.business.Country) Profile(com.orientechnologies.orient.test.domain.whiz.Profile) Test(org.testng.annotations.Test)

Example 2 with Country

use of com.orientechnologies.orient.test.domain.business.Country in project orientdb by orientechnologies.

the class CRUDObjectPhysicalTestSchemaFull method createLinked.

@Test(dependsOnMethods = "testSaveMultiCircular")
public void createLinked() {
    long profiles = database.countClass("Profile");
    Profile neo = new Profile("Neo").setValue("test").setLocation(new Address("residence", new City(new Country("Spain"), "Madrid"), "Rio de Castilla"));
    neo.addFollowing(new Profile("Morpheus"));
    neo.addFollowing(new Profile("Trinity"));
    database.save(neo);
    Assert.assertEquals(database.countClass("Profile"), profiles + 3);
}
Also used : Address(com.orientechnologies.orient.test.domain.business.Address) Country(com.orientechnologies.orient.test.domain.business.Country) City(com.orientechnologies.orient.test.domain.business.City) Profile(com.orientechnologies.orient.test.domain.whiz.Profile) Test(org.testng.annotations.Test)

Example 3 with Country

use of com.orientechnologies.orient.test.domain.business.Country in project orientdb by orientechnologies.

the class ObjectDetachingTest method createAnnotatedObjects.

@Test
public void createAnnotatedObjects() {
    database.getEntityManager().registerEntityClasses("com.orientechnologies.orient.test.domain.business");
    database.getEntityManager().registerEntityClasses("com.orientechnologies.orient.test.domain.whiz");
    database.getEntityManager().registerEntityClasses("com.orientechnologies.orient.test.domain.base");
    Country austria = new Country("Austria");
    City graz = new City(austria, "Graz");
    graz = database.save(graz);
    account = new Account();
    account = database.save(account);
    profile = new Profile();
    profile = database.save(profile);
}
Also used : Account(com.orientechnologies.orient.test.domain.business.Account) Country(com.orientechnologies.orient.test.domain.business.Country) City(com.orientechnologies.orient.test.domain.business.City) Profile(com.orientechnologies.orient.test.domain.whiz.Profile) Test(org.testng.annotations.Test) EnumTest(com.orientechnologies.orient.test.domain.base.EnumTest)

Example 4 with Country

use of com.orientechnologies.orient.test.domain.business.Country in project orientdb by orientechnologies.

the class ObjectDetachingTest method testInsertCommit.

@Test(dependsOnMethods = "testOrientObjectIdPlusVersionAnnotationsInTx")
public void testInsertCommit() {
    String initialCountryName = "insertCommit";
    Country country = new Country(initialCountryName);
    long initCount = database.countClass(Country.class);
    database.begin();
    country = (Country) database.save(country);
    database.commit();
    Assert.assertEquals(database.countClass(Country.class), initCount + 1);
    Assert.assertNotNull(country.getId());
    Assert.assertNotNull(country.getVersion());
    Country found = (Country) database.load((ORecordId) country.getId());
    Assert.assertNotNull(found);
    Assert.assertEquals(country.getName(), found.getName());
}
Also used : Country(com.orientechnologies.orient.test.domain.business.Country) ORecordId(com.orientechnologies.orient.core.id.ORecordId) Test(org.testng.annotations.Test) EnumTest(com.orientechnologies.orient.test.domain.base.EnumTest)

Example 5 with Country

use of com.orientechnologies.orient.test.domain.business.Country in project orientdb by orientechnologies.

the class ObjectDetachingTest 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());
}
Also used : Country(com.orientechnologies.orient.test.domain.business.Country) Test(org.testng.annotations.Test) EnumTest(com.orientechnologies.orient.test.domain.base.EnumTest)

Aggregations

Country (com.orientechnologies.orient.test.domain.business.Country)22 Test (org.testng.annotations.Test)22 EnumTest (com.orientechnologies.orient.test.domain.base.EnumTest)16 ORecordId (com.orientechnologies.orient.core.id.ORecordId)6 Address (com.orientechnologies.orient.test.domain.business.Address)6 City (com.orientechnologies.orient.test.domain.business.City)6 Profile (com.orientechnologies.orient.test.domain.whiz.Profile)6 Account (com.orientechnologies.orient.test.domain.business.Account)4 ORID (com.orientechnologies.orient.core.id.ORID)2 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)1