Search in sources :

Example 41 with Profile

use of com.orientechnologies.orient.test.domain.whiz.Profile in project orientdb by orientechnologies.

the class ObjectTreeTest method testQueryCircular.

@Test(dependsOnMethods = "testSaveCircularLink")
public void testQueryCircular() {
    List<Profile> result = database.query(new OSQLSynchQuery<ODocument>("select * from Profile"));
    Profile parent;
    for (Profile r : result) {
        System.out.println(r.getNick());
        parent = r.getInvitedBy();
        if (parent != null)
            System.out.println("- parent: " + parent.getName() + " " + parent.getSurname());
    }
}
Also used : Profile(com.orientechnologies.orient.test.domain.whiz.Profile) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 42 with Profile

use of com.orientechnologies.orient.test.domain.whiz.Profile in project orientdb by orientechnologies.

the class ObjectDetachingTest method testObjectSerialization.

public void testObjectSerialization() {
    Profile profile = new Profile("NonProxiedObjectToDelete", "NonProxiedObjectToDelete", "NonProxiedObjectToDelete", null);
    profile = database.save(profile);
    ODocument originalDoc = database.getRecordByUserObject(profile, false);
    // DETACH TEST
    ODocument serializedDoc = database.getRecordByUserObject(database.detach(profile, true), false);
    Assert.assertTrue(originalDoc.equals(serializedDoc));
    Assert.assertTrue(originalDoc.hasSameContentOf(serializedDoc));
    // DETACH ALL TEST
    serializedDoc = database.getRecordByUserObject(database.detachAll(profile, true), false);
    Assert.assertTrue(originalDoc.equals(serializedDoc));
    Assert.assertTrue(originalDoc.hasSameContentOf(serializedDoc));
    database.delete(profile);
}
Also used : Profile(com.orientechnologies.orient.test.domain.whiz.Profile) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 43 with Profile

use of com.orientechnologies.orient.test.domain.whiz.Profile 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);
}
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 44 with Profile

use of com.orientechnologies.orient.test.domain.whiz.Profile in project orientdb by orientechnologies.

the class ObjectTreeTestSchemaFull method testQueryCircular.

@Test(dependsOnMethods = "testSaveCircularLink")
public void testQueryCircular() {
    List<Profile> result = database.query(new OSQLSynchQuery<ODocument>("select * from Profile"));
    Profile parent;
    for (Profile r : result) {
        // System.out.println(r.getNick());
        parent = r.getInvitedBy();
        if (parent != null)
            System.out.println("- parent: " + parent.getName() + " " + parent.getSurname());
    }
}
Also used : Profile(com.orientechnologies.orient.test.domain.whiz.Profile) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 45 with Profile

use of com.orientechnologies.orient.test.domain.whiz.Profile in project orientdb by orientechnologies.

the class ObjectDetachingTestSchemaFull method testObjectSerialization.

@Test(dependsOnMethods = "testReloadAndDetachAll")
public void testObjectSerialization() {
    Profile profile = new Profile("NonProxiedObjectToDelete", "NonProxiedObjectToDelete", "NonProxiedObjectToDelete", null);
    profile = database.save(profile);
    ODocument originalDoc = database.getRecordByUserObject(profile, false);
    // DETACH TEST
    ODocument serializedDoc = database.getRecordByUserObject(database.detach(profile, true), false);
    Assert.assertTrue(originalDoc.equals(serializedDoc));
    Assert.assertTrue(originalDoc.hasSameContentOf(serializedDoc));
    // DETACH ALL TEST
    serializedDoc = database.getRecordByUserObject(database.detachAll(profile, true), false);
    Assert.assertTrue(originalDoc.equals(serializedDoc));
    Assert.assertTrue(originalDoc.hasSameContentOf(serializedDoc));
    database.delete(profile);
}
Also used : Profile(com.orientechnologies.orient.test.domain.whiz.Profile) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test) EnumTest(com.orientechnologies.orient.test.domain.base.EnumTest)

Aggregations

Profile (com.orientechnologies.orient.test.domain.whiz.Profile)50 Test (org.testng.annotations.Test)46 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)19 DatabaseAbstractTest (com.orientechnologies.DatabaseAbstractTest)14 OrientTest (com.orientechnologies.orient.test.database.base.OrientTest)14 Address (com.orientechnologies.orient.test.domain.business.Address)10 Country (com.orientechnologies.orient.test.domain.business.Country)10 OStorageProxy (com.orientechnologies.orient.core.storage.OStorageProxy)9 City (com.orientechnologies.orient.test.domain.business.City)6 ORecordId (com.orientechnologies.orient.core.id.ORecordId)4 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)4 EnumTest (com.orientechnologies.orient.test.domain.base.EnumTest)4 OLazyObjectSetInterface (com.orientechnologies.orient.core.db.object.OLazyObjectSetInterface)2 OProperty (com.orientechnologies.orient.core.metadata.schema.OProperty)2 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)2 OObjectDatabaseTx (com.orientechnologies.orient.object.db.OObjectDatabaseTx)2 Account (com.orientechnologies.orient.test.domain.business.Account)2 Proxy (javassist.util.proxy.Proxy)2 ORecordDuplicatedException (com.orientechnologies.orient.core.storage.ORecordDuplicatedException)1 OSchemaProxyObject (com.orientechnologies.orient.object.metadata.schema.OSchemaProxyObject)1