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);
}
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);
}
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);
}
}
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);
}
}
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);
}
Aggregations