Search in sources :

Example 21 with Profile

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

the class ObjectTreeTestSchemaFull method testSaveCircularLink.

@Test(dependsOnMethods = "testCityEquality")
public void testSaveCircularLink() {
    Profile winston = database.newInstance(Profile.class, "WChurcill", "Winston", "Churcill", null);
    winston.setLocation(database.newInstance(Address.class, "Residence", database.newInstance(City.class, database.newInstance(Country.class, "England"), "London"), "unknown"));
    Profile nicholas = database.newInstance(Profile.class, "NChurcill", "Nicholas ", "Churcill", winston);
    nicholas.setLocation(winston.getLocation());
    nicholas.setInvitedBy(winston);
    winston.setInvitedBy(nicholas);
    database.save(nicholas);
}
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 22 with Profile

use of com.orientechnologies.orient.test.domain.whiz.Profile 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 23 with Profile

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

the class IndexTest method testIndexRebuildDuringDetachAllNonProxiedObjectDelete.

@Test(dependsOnMethods = "testIndexRebuildDuringNonProxiedObjectDelete")
public void testIndexRebuildDuringDetachAllNonProxiedObjectDelete() {
    Profile profile = new Profile("NonProxiedObjectToDelete", "NonProxiedObjectToDelete", "NonProxiedObjectToDelete", null);
    profile = database.save(profile);
    OIndexManager idxManager = database.getMetadata().getIndexManager();
    OIndex<?> nickIndex = idxManager.getIndex("Profile.nick");
    Assert.assertTrue(nickIndex.contains("NonProxiedObjectToDelete"));
    final Profile loadedProfile = database.load(new ORecordId(profile.getId()));
    database.delete(database.detachAll(loadedProfile, true));
    Assert.assertFalse(nickIndex.contains("NonProxiedObjectToDelete"));
}
Also used : Profile(com.orientechnologies.orient.test.domain.whiz.Profile) ORecordId(com.orientechnologies.orient.core.id.ORecordId) Test(org.testng.annotations.Test) DatabaseAbstractTest(com.orientechnologies.DatabaseAbstractTest) OrientTest(com.orientechnologies.orient.test.database.base.OrientTest)

Example 24 with Profile

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

the class IndexTest method populateIndexDocuments.

public void populateIndexDocuments() {
    for (int i = 0; i <= 5; i++) {
        final Profile profile = new Profile("ZZZJayLongNickIndex" + i, "NickIndex" + i, "NolteIndex" + i, null);
        database.save(profile);
    }
    for (int i = 0; i <= 5; i++) {
        final Profile profile = new Profile("00" + i, "NickIndex" + i, "NolteIndex" + i, null);
        database.save(profile);
    }
}
Also used : Profile(com.orientechnologies.orient.test.domain.whiz.Profile)

Example 25 with Profile

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

the class IndexTest method testIndexSize.

@Test(dependsOnMethods = "testDuplicatedIndexOnUnique")
public void testIndexSize() {
    List<Profile> result = database.command(new OSQLSynchQuery<Profile>("select * from Profile where nick is not null")).execute();
    int profileSize = result.size();
    database.getMetadata().getIndexManager().reload();
    Assert.assertEquals(database.getMetadata().getIndexManager().getIndex("Profile.nick").getSize(), profileSize);
    for (int i = 0; i < 10; i++) {
        Profile profile = new Profile("Yay-" + i, "Jay", "Miner", null);
        database.save(profile);
        profileSize++;
        Assert.assertNotNull(database.getMetadata().getIndexManager().getIndex("Profile.nick").get("Yay-" + i));
    }
}
Also used : OSQLSynchQuery(com.orientechnologies.orient.core.sql.query.OSQLSynchQuery) Profile(com.orientechnologies.orient.test.domain.whiz.Profile) Test(org.testng.annotations.Test) DatabaseAbstractTest(com.orientechnologies.DatabaseAbstractTest) OrientTest(com.orientechnologies.orient.test.database.base.OrientTest)

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