Search in sources :

Example 31 with Profile

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

the class IndexTest method testIndexInMinorEqualsSelect.

@Test(dependsOnMethods = "populateIndexDocuments")
public void testIndexInMinorEqualsSelect() {
    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", "002"));
    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)

Example 32 with Profile

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

the class IndexTest method testIndexBetweenSelect.

@Test(dependsOnMethods = "populateIndexDocuments")
public void testIndexBetweenSelect() {
    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 between '001' and '004'")).execute();
    final List<String> expectedNicks = new ArrayList<String>(Arrays.asList("001", "002", "003", "004"));
    if (!oldRecording) {
        Orient.instance().getProfiler().stopRecording();
    }
    Assert.assertEquals(result.size(), 4);
    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 33 with Profile

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

the class IndexTest method testIndexInUniqueIndex.

@Test(dependsOnMethods = "populateIndexDocuments")
public void testIndexInUniqueIndex() {
    final OProperty nickProperty = database.getMetadata().getSchema().getClass("Profile").getProperty("nick");
    Assert.assertEquals(nickProperty.getIndexes().iterator().next().getType(), OClass.INDEX_TYPE.UNIQUE.toString());
    final boolean localStorage = !(database.getStorage() instanceof OStorageProxy);
    boolean oldRecording = true;
    long indexQueries = 0L;
    if (localStorage) {
        oldRecording = Orient.instance().getProfiler().isRecording();
        if (!oldRecording) {
            Orient.instance().getProfiler().startRecording();
        }
        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 in ['ZZZJayLongNickIndex0' ,'ZZZJayLongNickIndex1', 'ZZZJayLongNickIndex2']")).execute();
    final List<String> expectedSurnames = new ArrayList<String>(Arrays.asList("NolteIndex0", "NolteIndex1", "NolteIndex2"));
    if (localStorage && !oldRecording) {
        Orient.instance().getProfiler().stopRecording();
    }
    Assert.assertEquals(result.size(), 3);
    for (final Profile profile : result) {
        expectedSurnames.remove(profile.getSurname());
    }
    Assert.assertEquals(expectedSurnames.size(), 0);
    if (localStorage) {
        final long newIndexQueries = Orient.instance().getProfiler().getCounter("db.demo.query.indexUsed");
        Assert.assertEquals(newIndexQueries, indexQueries + 1);
    }
}
Also used : OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty) 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 34 with Profile

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

the class IndexTest method testIndexInNotUniqueIndex.

@Test(dependsOnMethods = { "createNotUniqueIndexOnNick", "populateIndexDocuments" })
public void testIndexInNotUniqueIndex() {
    final OProperty nickProperty = database.getMetadata().getSchema().getClass("Profile").getProperty("nick");
    Assert.assertEquals(nickProperty.getIndexes().iterator().next().getType(), OClass.INDEX_TYPE.NOTUNIQUE.toString());
    final boolean localStorage = !(database.getStorage() instanceof OStorageProxy);
    boolean oldRecording = true;
    long indexQueries = 0L;
    if (localStorage) {
        oldRecording = Orient.instance().getProfiler().isRecording();
        if (!oldRecording) {
            Orient.instance().getProfiler().startRecording();
        }
        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 in ['ZZZJayLongNickIndex0' ,'ZZZJayLongNickIndex1', 'ZZZJayLongNickIndex2']")).execute();
    final List<String> expectedSurnames = new ArrayList<String>(Arrays.asList("NolteIndex0", "NolteIndex1", "NolteIndex2"));
    if (localStorage && !oldRecording) {
        Orient.instance().getProfiler().stopRecording();
    }
    Assert.assertEquals(result.size(), 3);
    for (final Profile profile : result) {
        expectedSurnames.remove(profile.getSurname());
    }
    Assert.assertEquals(expectedSurnames.size(), 0);
    if (localStorage) {
        final long newIndexQueries = Orient.instance().getProfiler().getCounter("db.demo.query.indexUsed");
        Assert.assertEquals(newIndexQueries, indexQueries + 1);
    }
}
Also used : OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty) 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 35 with Profile

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

the class HookTest method testHookCreate.

@Test(dependsOnMethods = "testHooksIsRegistered")
public void testHookCreate() throws IOException {
    p = new Profile("HookTest");
    // TEST HOOKS ON CREATE
    Assert.assertEquals(callbackCount, 0);
    database.save(p);
    Assert.assertEquals(callbackCount, 11);
}
Also used : Profile(com.orientechnologies.orient.test.domain.whiz.Profile) Test(org.testng.annotations.Test)

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