use of com.orientechnologies.orient.test.domain.whiz.Profile in project orientdb by orientechnologies.
the class CRUDObjectPhysicalTest 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 CRUDObjectPhysicalTest method queryWithRidAsParameters.
@Test
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 CRUDObjectPhysicalTest 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 queryWithObjectAsParameter.
@Test(dependsOnMethods = "createLinked")
public void queryWithObjectAsParameter() {
database.getMetadata().getSchema().reload();
final OSQLSynchQuery<Profile> query = new OSQLSynchQuery<Profile>("select from Profile where name = :name and surname = :surname");
HashMap<String, String> params = new HashMap<String, String>();
params.put("name", "Barack");
params.put("surname", "Obama");
List<Profile> result = database.query(query, params);
Assert.assertTrue(result.size() != 0);
Profile obama = result.get(0);
result = database.query(new OSQLSynchQuery<Profile>("select from Profile where followings contains ( @Rid = :who )"), obama);
Assert.assertTrue(result.size() != 0);
}
use of com.orientechnologies.orient.test.domain.whiz.Profile in project orientdb by orientechnologies.
the class CRUDObjectPhysicalTestSchemaFull method testSaveMultiCircular.
@Test(dependsOnMethods = "testUpdate")
public void testSaveMultiCircular() {
database = OObjectDatabasePool.global().acquire(url, "admin", "admin");
try {
startRecordNumber = database.countClusterElements("Profile");
Profile bObama = database.newInstance(Profile.class, "ThePresident", "Barack", "Obama", null);
bObama.setLocation(database.newInstance(Address.class, "Residence", database.newInstance(City.class, database.newInstance(Country.class, "Hawaii"), "Honolulu"), "unknown"));
bObama.addFollower(database.newInstance(Profile.class, "PresidentSon1", "Malia Ann", "Obama", bObama));
bObama.addFollower(database.newInstance(Profile.class, "PresidentSon2", "Natasha", "Obama", bObama));
database.save(bObama);
} finally {
database.close();
}
}
Aggregations