Search in sources :

Example 1 with OCommandPredicate

use of com.orientechnologies.orient.core.command.OCommandPredicate in project orientdb by orientechnologies.

the class TraverseTest method traverseAPIIterating.

@Test
public void traverseAPIIterating() {
    int cycles = 0;
    for (OIdentifiable id : new OTraverse().target(database.browseClass("Movie").iterator()).predicate(new OCommandPredicate() {

        @Override
        public Object evaluate(OIdentifiable iRecord, ODocument iCurrentResult, OCommandContext iContext) {
            return ((Integer) iContext.getVariable("depth")) <= 2;
        }
    })) {
        cycles++;
    }
    Assert.assertTrue(cycles > 0);
}
Also used : OCommandContext(com.orientechnologies.orient.core.command.OCommandContext) OTraverse(com.orientechnologies.orient.core.command.traverse.OTraverse) OCommandPredicate(com.orientechnologies.orient.core.command.OCommandPredicate) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Aggregations

OCommandContext (com.orientechnologies.orient.core.command.OCommandContext)1 OCommandPredicate (com.orientechnologies.orient.core.command.OCommandPredicate)1 OTraverse (com.orientechnologies.orient.core.command.traverse.OTraverse)1 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)1 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)1 Test (org.testng.annotations.Test)1