Search in sources :

Example 6 with Statement

use of org.neo4j.driver.v1.Statement in project cypher-for-gremlin by opencypher.

the class GremlinServerStatementResultTest method map.

@Test
public void map() {
    List<Map<String, Object>> results = Arrays.asList(getRow(1), getRow(2));
    StatementResult statementResult = new GremlinServerDriver.GremlinServerStatementResult(serverInfo, statement, results.iterator());
    assertThat(statementResult.list(r -> r.get(KEY2).asString())).containsExactly("value1", "value2");
}
Also used : StatementResult(org.neo4j.driver.v1.StatementResult) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 7 with Statement

use of org.neo4j.driver.v1.Statement in project cypher-for-gremlin by opencypher.

the class GremlinServerStatementResultTest method create.

@Test
public void create() {
    List<Map<String, Object>> results = Arrays.asList(getRow(1), getRow(2), getRow(3));
    StatementResult statementResult = new GremlinServerDriver.GremlinServerStatementResult(serverInfo, statement, results.iterator());
    assertThat(statementResult.keys()).containsExactly(KEY1, KEY2);
    assertThat(statementResult.peek().get(KEY1).asInt()).isEqualTo(1);
    assertThat(statementResult.hasNext()).isTrue();
    assertThat(statementResult.next().get(KEY1).asInt()).isEqualTo(1);
    assertThat(statementResult.hasNext()).isTrue();
    assertThat(statementResult.next().get(KEY1).asInt()).isEqualTo(2);
    assertThat(statementResult.hasNext()).isTrue();
    // see org.neo4j.driver.internal.InternalStatementResult#list()
    assertThat(statementResult.list()).hasSize(1);
    assertThat(statementResult.hasNext()).isFalse();
    assertThat(statementResult.summary().server()).isEqualTo(serverInfo);
}
Also used : StatementResult(org.neo4j.driver.v1.StatementResult) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 8 with Statement

use of org.neo4j.driver.v1.Statement in project cypher-for-gremlin by opencypher.

the class GremlinServerStatementResultTest method singleZero.

@Test(expected = NoSuchRecordException.class)
public void singleZero() {
    StatementResult statementResult = new GremlinServerDriver.GremlinServerStatementResult(serverInfo, statement, new ArrayList<Map<String, Object>>().iterator());
    statementResult.single();
}
Also used : StatementResult(org.neo4j.driver.v1.StatementResult) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

StatementResult (org.neo4j.driver.v1.StatementResult)8 Test (org.junit.Test)6 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Record (org.neo4j.driver.v1.Record)2 NoSuchRecordException (org.neo4j.driver.v1.exceptions.NoSuchRecordException)2 ArrayList (java.util.ArrayList)1 Session (org.neo4j.driver.v1.Session)1 Statement (org.neo4j.driver.v1.Statement)1 Value (org.neo4j.driver.v1.Value)1 ServiceUnavailableException (org.neo4j.driver.v1.exceptions.ServiceUnavailableException)1 TransientException (org.neo4j.driver.v1.exceptions.TransientException)1 Relationship (org.neo4j.driver.v1.types.Relationship)1 PathInfoData (org.openkilda.messaging.info.event.PathInfoData)1 PathNode (org.openkilda.messaging.info.event.PathNode)1 ImmutablePair (org.openkilda.messaging.model.ImmutablePair)1 NetworkException (org.structr.api.NetworkException)1 NotFoundException (org.structr.api.NotFoundException)1 QueryResult (org.structr.api.QueryResult)1 RetryException (org.structr.api.RetryException)1