use of com.orientechnologies.orient.test.domain.whiz.Profile in project orientdb by orientechnologies.
the class IndexTest method testIndexInMajorSelect.
@Test(dependsOnMethods = "populateIndexDocuments")
public void testIndexInMajorSelect() {
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("ZZZJayLongNickIndex4", "ZZZJayLongNickIndex5"));
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);
}
use of com.orientechnologies.orient.test.domain.whiz.Profile in project orientdb by orientechnologies.
the class IndexTest method testDuplicatedIndexOnUnique.
public void testDuplicatedIndexOnUnique() {
Profile jayMiner = new Profile("Jay", "Jay", "Miner", null);
database.save(jayMiner);
Profile jacobMiner = new Profile("Jay", "Jacob", "Miner", null);
try {
database.save(jacobMiner);
// IT SHOULD GIVE ERROR ON DUPLICATED KEY
Assert.assertTrue(false);
} catch (ORecordDuplicatedException e) {
Assert.assertTrue(true);
}
}
use of com.orientechnologies.orient.test.domain.whiz.Profile in project orientdb by orientechnologies.
the class ObjectTreeTest method testCityEquality.
@Test(dependsOnMethods = "testCitySaving")
public void testCityEquality() {
List<Profile> resultset = database.query(new OSQLSynchQuery<Object>("select from profile where location.city.name = 'Rome'"));
Assert.assertEquals(resultset.size(), 2);
Profile p1 = resultset.get(0);
Profile p2 = resultset.get(1);
Assert.assertNotSame(p1, p2);
Assert.assertSame(OObjectEntitySerializer.getDocument((Proxy) p1.getLocation().getCity()), OObjectEntitySerializer.getDocument((Proxy) p2.getLocation().getCity()));
}
use of com.orientechnologies.orient.test.domain.whiz.Profile in project orientdb by orientechnologies.
the class ObjectTreeTest 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);
}
use of com.orientechnologies.orient.test.domain.whiz.Profile in project orientdb by orientechnologies.
the class ObjectTreeTest method iteratorShouldTerminate.
@Test
public void iteratorShouldTerminate() {
OObjectDatabaseTx db = OObjectDatabasePool.global().acquire(url, "admin", "admin");
try {
db.getEntityManager().registerEntityClass(Profile.class);
db.begin();
Profile person = new Profile();
person.setNick("Guy1");
person.setName("Guy");
person.setSurname("Ritchie");
person = db.save(person);
db.commit();
db.begin();
db.delete(person);
db.commit();
db.begin();
Profile person2 = new Profile();
person2.setNick("Guy2");
person2.setName("Guy");
person2.setSurname("Brush");
person2 = db.save(person2);
OObjectIteratorClass<Profile> it = db.browseClass(Profile.class);
while (it.hasNext()) {
System.out.println(it.next());
}
db.commit();
} finally {
db.close();
}
}
Aggregations