Search in sources :

Example 26 with Profile

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

the class IndexTest method testIndexRebuildDuringNonProxiedObjectDelete.

@Test
public void testIndexRebuildDuringNonProxiedObjectDelete() {
    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.detach(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 27 with Profile

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

the class IndexTest method testDuplicatedIndexOnNotUnique.

@Test(dependsOnMethods = "testChangeOfIndexToNotUnique")
public void testDuplicatedIndexOnNotUnique() {
    Profile nickNolte = new Profile("Jay", "Nick", "Nolte", null);
    database.save(nickNolte);
}
Also used : 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)

Example 28 with Profile

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

the class IndexTest method testIndexInMinorSelect.

@Test(dependsOnMethods = "populateIndexDocuments")
public void testIndexInMinorSelect() {
    if (database.getStorage() instanceof OStorageProxy) {
        return;
    }
    final boolean oldRecording = Orient.instance().getProfiler().isRecording();
    if (!oldRecording) {
        Orient.instance().getProfiler().startRecording();
    }
    long indexQueries = Orient.instance().getProfiler().getCounter("db.demo.query.indexUsed");
    if (indexQueries < 0) {
        indexQueries = 0;
    }
    final List<Profile> result = database.command(new OSQLSynchQuery<Profile>("select * from Profile where nick < '002'")).execute();
    final List<String> expectedNicks = new ArrayList<String>(Arrays.asList("000", "001"));
    if (!oldRecording) {
        Orient.instance().getProfiler().stopRecording();
    }
    Assert.assertEquals(result.size(), 2);
    for (Profile profile : result) {
        expectedNicks.remove(profile.getNick());
    }
    Assert.assertEquals(expectedNicks.size(), 0);
    long newIndexQueries = Orient.instance().getProfiler().getCounter("db.demo.query.indexUsed");
    Assert.assertEquals(newIndexQueries, indexQueries + 1);
}
Also used : OStorageProxy(com.orientechnologies.orient.core.storage.OStorageProxy) 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)

Example 29 with Profile

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

the class IndexTest method testIndexInComplexSelectOne.

@Test(dependsOnMethods = "populateIndexDocuments")
public void testIndexInComplexSelectOne() {
    if (database.getStorage() instanceof OStorageProxy) {
        return;
    }
    final boolean oldRecording = Orient.instance().getProfiler().isRecording();
    if (!oldRecording) {
        Orient.instance().getProfiler().startRecording();
    }
    long indexQueries = Orient.instance().getProfiler().getCounter("db.demo.query.indexUsed");
    if (indexQueries < 0) {
        indexQueries = 0;
    }
    final List<Profile> result = database.command(new OSQLSynchQuery<Profile>("select * from Profile where (name = 'Giuseppe' OR name <> 'Napoleone')" + " AND (nick is not null AND (name = 'Giuseppe' OR name <> 'Napoleone') AND (nick >= 'ZZZJayLongNickIndex3'))")).execute();
    if (!oldRecording) {
        Orient.instance().getProfiler().stopRecording();
    }
    final List<String> expectedNicks = new ArrayList<String>(Arrays.asList("ZZZJayLongNickIndex3", "ZZZJayLongNickIndex4", "ZZZJayLongNickIndex5"));
    Assert.assertEquals(result.size(), 3);
    for (Profile profile : result) {
        expectedNicks.remove(profile.getNick());
    }
    Assert.assertEquals(expectedNicks.size(), 0);
    long newIndexQueries = Orient.instance().getProfiler().getCounter("db.demo.query.indexUsed");
    Assert.assertEquals(newIndexQueries, indexQueries + 1);
}
Also used : OStorageProxy(com.orientechnologies.orient.core.storage.OStorageProxy) 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)

Example 30 with Profile

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

the class IndexTest method testIndexInMajorEqualsSelect.

@Test(dependsOnMethods = "populateIndexDocuments")
public void testIndexInMajorEqualsSelect() {
    if (database.getStorage() instanceof OStorageProxy) {
        return;
    }
    final boolean oldRecording = Orient.instance().getProfiler().isRecording();
    if (!oldRecording) {
        Orient.instance().getProfiler().startRecording();
    }
    long indexQueries = Orient.instance().getProfiler().getCounter("db.demo.query.indexUsed");
    if (indexQueries < 0) {
        indexQueries = 0;
    }
    final List<Profile> result = database.command(new OSQLSynchQuery<Profile>("select * from Profile where nick >= 'ZZZJayLongNickIndex3'")).execute();
    final List<String> expectedNicks = new ArrayList<String>(Arrays.asList("ZZZJayLongNickIndex3", "ZZZJayLongNickIndex4", "ZZZJayLongNickIndex5"));
    if (!oldRecording) {
        Orient.instance().getProfiler().stopRecording();
    }
    Assert.assertEquals(result.size(), 3);
    for (Profile profile : result) {
        expectedNicks.remove(profile.getNick());
    }
    Assert.assertEquals(expectedNicks.size(), 0);
    long newIndexQueries = Orient.instance().getProfiler().getCounter("db.demo.query.indexUsed");
    Assert.assertEquals(newIndexQueries, indexQueries + 1);
}
Also used : OStorageProxy(com.orientechnologies.orient.core.storage.OStorageProxy) 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