Search in sources :

Example 26 with OBasicCommandContext

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

the class OSQLFunctionShortestPathTest method testLong.

@Test
public void testLong() throws Exception {
    final List<ORID> result = function.execute(null, null, null, new Object[] { vertices.get(1), vertices.get(20) }, new OBasicCommandContext());
    assertEquals(11, result.size());
    assertEquals(vertices.get(1).getId(), result.get(0));
    assertEquals(vertices.get(3).getId(), result.get(1));
    int next = 2;
    for (int i = 4; i <= 20; i += 2) {
        assertEquals(vertices.get(i).getId(), result.get(next++));
    }
}
Also used : OBasicCommandContext(com.orientechnologies.orient.core.command.OBasicCommandContext) ORID(com.orientechnologies.orient.core.id.ORID) Test(org.junit.Test)

Example 27 with OBasicCommandContext

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

the class OSQLFunctionShortestPathTest method testMaxDepth3.

@Test
public void testMaxDepth3() throws Exception {
    Map<String, Object> additionalParams = new HashMap<String, Object>();
    additionalParams.put(OSQLFunctionShortestPath.PARAM_MAX_DEPTH, 10);
    final List<ORID> result = function.execute(null, null, null, new Object[] { vertices.get(1), vertices.get(20), null, null, additionalParams }, new OBasicCommandContext());
    assertEquals(0, result.size());
}
Also used : OBasicCommandContext(com.orientechnologies.orient.core.command.OBasicCommandContext) HashMap(java.util.HashMap) ORID(com.orientechnologies.orient.core.id.ORID) Test(org.junit.Test)

Example 28 with OBasicCommandContext

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

the class OSQLFunctionShortestPathTest method testExecuteOut.

@Test
public void testExecuteOut() throws Exception {
    final List<ORID> result = function.execute(null, null, null, new Object[] { vertices.get(1), vertices.get(4), "out", null }, new OBasicCommandContext());
    assertEquals(4, result.size());
    assertEquals(vertices.get(1).getId(), result.get(0));
    assertEquals(vertices.get(2).getId(), result.get(1));
    assertEquals(vertices.get(3).getId(), result.get(2));
    assertEquals(vertices.get(4).getId(), result.get(3));
}
Also used : OBasicCommandContext(com.orientechnologies.orient.core.command.OBasicCommandContext) ORID(com.orientechnologies.orient.core.id.ORID) Test(org.junit.Test)

Example 29 with OBasicCommandContext

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

the class CRUDDocumentValidationTest method testNullComparison.

@Test
public void testNullComparison() {
    // given
    ODocument doc1 = new ODocument().field("testField", (Object) null);
    ODocument doc2 = new ODocument().field("testField", (Object) null);
    ODocumentComparator comparator = new ODocumentComparator(Collections.singletonList(new OPair<String, String>("testField", "asc")), new OBasicCommandContext());
    Assert.assertEquals(comparator.compare(doc1, doc2), 0);
}
Also used : OBasicCommandContext(com.orientechnologies.orient.core.command.OBasicCommandContext) OPair(com.orientechnologies.common.util.OPair) ODocumentComparator(com.orientechnologies.orient.core.record.impl.ODocumentComparator) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Aggregations

OBasicCommandContext (com.orientechnologies.orient.core.command.OBasicCommandContext)29 Test (org.junit.Test)22 HashMap (java.util.HashMap)16 OrientVertex (com.tinkerpop.blueprints.impls.orient.OrientVertex)13 ORID (com.orientechnologies.orient.core.id.ORID)8 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)6 Test (org.testng.annotations.Test)5 ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)3 OFunction (com.orientechnologies.orient.core.metadata.function.OFunction)3 OCommandContext (com.orientechnologies.orient.core.command.OCommandContext)2 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)2 OException (com.orientechnologies.common.exception.OException)1 OPair (com.orientechnologies.common.util.OPair)1 OCommandScriptException (com.orientechnologies.orient.core.command.script.OCommandScriptException)1 ODocumentComparator (com.orientechnologies.orient.core.record.impl.ODocumentComparator)1 OETLBaseTest (com.orientechnologies.orient.etl.OETLBaseTest)1 OHttpRequestWrapper (com.orientechnologies.orient.server.network.protocol.http.OHttpRequestWrapper)1 OHttpResponseWrapper (com.orientechnologies.orient.server.network.protocol.http.OHttpResponseWrapper)1 IOException (java.io.IOException)1