use of com.orientechnologies.orient.test.domain.whiz.Profile in project orientdb by orientechnologies.
the class CRUDObjectPhysicalTestSchemaFull method queryCross3Levels.
@Test(dependsOnMethods = "queryPerFloat")
public void queryCross3Levels() {
database.getMetadata().getSchema().reload();
final List<Profile> result = database.query(new OSQLSynchQuery<Profile>("select from Profile where location.city.country.name = 'Spain'"));
Assert.assertTrue(result.size() > 0);
Profile profile;
for (int i = 0; i < result.size(); ++i) {
profile = result.get(i);
Assert.assertEquals(profile.getLocation().getCity().getCountry().getName(), "Spain");
}
}
use of com.orientechnologies.orient.test.domain.whiz.Profile in project orientdb by orientechnologies.
the class CRUDObjectPhysicalTestSchemaFull method checkLazyLoadingOff.
@Test(dependsOnMethods = "createLinked")
public void checkLazyLoadingOff() {
database.setLazyLoading(false);
for (Profile obj : database.browseClass(Profile.class).setFetchPlan("*:1")) {
Assert.assertTrue(!(obj.getFollowings() instanceof OLazyObjectSetInterface) || ((OLazyObjectSetInterface<Profile>) obj.getFollowings()).isConverted());
Assert.assertTrue(!(obj.getFollowers() instanceof OLazyObjectSetInterface) || ((OLazyObjectSetInterface<Profile>) obj.getFollowers()).isConverted());
if (obj.getNick().equals("Neo")) {
Assert.assertEquals(obj.getFollowers().size(), 0);
Assert.assertEquals(obj.getFollowings().size(), 2);
} else if (obj.getNick().equals("Morpheus") || obj.getNick().equals("Trinity")) {
Assert.assertEquals(obj.getFollowings().size(), 0);
Assert.assertEquals(obj.getFollowers().size(), 1);
Assert.assertTrue(obj.getFollowers().iterator().next() instanceof Profile);
}
}
}
use of com.orientechnologies.orient.test.domain.whiz.Profile in project orientdb by orientechnologies.
the class CRUDObjectPhysicalTestSchemaFull method queryWithRidStringAsParameters.
@Test(dependsOnMethods = "createLinked")
public void queryWithRidStringAsParameters() {
database.getMetadata().getSchema().reload();
Profile profile = (Profile) database.browseClass("Profile").next();
OSQLSynchQuery<Profile> query = new OSQLSynchQuery<Profile>("select from Profile where @rid = ?");
List<Profile> result = database.query(query, profile.getId());
Assert.assertEquals(result.size(), 1);
// TEST WITHOUT # AS PREFIX
query = new OSQLSynchQuery<Profile>("select from Profile where @rid = ?");
result = database.query(query, profile.getId().substring(1));
Assert.assertEquals(result.size(), 1);
}
use of com.orientechnologies.orient.test.domain.whiz.Profile in project orientdb by orientechnologies.
the class CRUDObjectPhysicalTestSchemaFull method queryWithRidAsParameters.
@Test(dependsOnMethods = "createLinked")
public void queryWithRidAsParameters() {
database.getMetadata().getSchema().reload();
Profile profile = (Profile) database.browseClass("Profile").next();
final OSQLSynchQuery<Profile> query = new OSQLSynchQuery<Profile>("select from Profile where @rid = ?");
List<Profile> result = database.query(query, new ORecordId(profile.getId()));
Assert.assertEquals(result.size(), 1);
}
use of com.orientechnologies.orient.test.domain.whiz.Profile in project orientdb by orientechnologies.
the class ObjectDetachingTestSchemaFull method testReloadAndDetachAll.
@Test(dependsOnMethods = "testDetachAllNonProxied")
public void testReloadAndDetachAll() {
// DELETE PREVIOUS TEST DATA
database.command(new OCommandSQL("delete from Profile where nick = 'Jack'")).execute();
// Open db
// Create the address without country
Address anAddress = new Address("Godewaersvelde");
anAddress = database.save(anAddress);
Address realAddress = database.detachAll(anAddress, true);
// Create the person
Profile aPerson = new Profile("Jack", "Jack", "Black", null);
aPerson.setLocation(realAddress);
aPerson = database.save(aPerson);
// Update the address by another way (another process for example)
City aCity = new City("Paris");
aCity = database.save(aCity);
String command = "update " + anAddress.getId() + " set city = " + database.getIdentity(aCity);
database.command(new OCommandSQL(command)).execute();
realAddress = database.reload(anAddress, true);
Assert.assertNotNull(realAddress.getCity());
// At this point, in OrientDB Studio everything is fine
// The address has the good country @rid, with version +1
// Now reload and detachAll the person
Profile newPerson = database.reload(aPerson, "*:-1", true);
Profile finalPerson = database.detachAll(newPerson, true);
// But with the reload, the country is null
// out = null
Assert.assertNotNull(finalPerson.getLocation().getCity());
// Same problem with query and detachAll
String query = "select from Profile where name = 'Jack' and surname = 'Black'";
newPerson = (Profile) database.query(new OSQLSynchQuery<Object>(query), new Object[0]).get(0);
finalPerson = database.detachAll(newPerson, true);
// out = null
Assert.assertNotNull(finalPerson.getLocation().getCity());
// Close db
}
Aggregations