Example #1
0
        /// <summary>
        /// Test creates a situation where streaming of a node fails when accessing node labels/properties.
        /// It fails because transaction is terminated. Bolt server should not send half-written message.
        /// Driver should receive a regular FAILURE message saying that transaction has been terminated.
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldTransmitStreamingFailure()
        public virtual void ShouldTransmitStreamingFailure()
        {
            using (Session session = _driver.session())
            {
                IDictionary <string, object> @params = new Dictionary <string, object>();
                @params["name1"] = RandomLongString();
                @params["name2"] = RandomLongString();
                session.run("CREATE (n1 :Person {name: $name1}), (n2 :Person {name: $name2}) RETURN n1, n2", @params).consume();

                StatementResult result = session.run("CALL test.readNodesReturnThemAndTerminateTheTransaction() YIELD node");

                assertTrue(result.hasNext());
                Record record = result.next();
                assertEquals("Person", Iterables.single(record.get(0).asNode().labels()));
                assertNotNull(record.get(0).asNode().get("name"));

                try
                {
                    result.hasNext();
                    fail("Exception expected");
                }
                catch (TransientException e)
                {
                    assertEquals(Org.Neo4j.Kernel.Api.Exceptions.Status_Transaction.Terminated.code().serialize(), e.code());
                }
            }
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mixingPeriodicCommitAndLoadCSVShouldWorkWithMapsWithinMaps() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MixingPeriodicCommitAndLoadCSVShouldWorkWithMapsWithinMaps()
        {
            using (Driver driver = GraphDatabase.driver(GraphDb.boltURI(), Configuration()), Session session = driver.session())
            {
                StatementResult result       = session.run("USING PERIODIC COMMIT " + (_lineCountInCSV - 1) + "\n" + "LOAD CSV FROM \"" + _url + "\" as row fieldterminator \" \"\n" + "MERGE (currentnode:Label5 {uuid:row[0]})\n" + "RETURN {outer:{node:currentnode}};");
                int             countOfNodes = 0;
                while (result.hasNext())
                {
                    IEnumerator <KeyValuePair <string, object> > iterator = result.next().get(0).asMap().entrySet().GetEnumerator();
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    assertTrue(iterator.hasNext());
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    iterator = ((IDictionary <string, object>)iterator.next().Value).SetOfKeyValuePairs().GetEnumerator();
                    while (iterator.MoveNext())
                    {
                        KeyValuePair <string, object> entry = iterator.Current;
                        assertEquals("node", entry.Key);
                        Node node = ( Node )entry.Value;
                        assertTrue(node.hasLabel("Label5"));
                        assertEquals(countOfNodes.ToString(), node.get("uuid").asString());
                        countOfNodes++;
                    }
                }

                assertEquals(_lineCountInCSV, countOfNodes);
            }
        }
Example #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mixingPeriodicCommitAndLoadCSVShouldWork2()
        public virtual void MixingPeriodicCommitAndLoadCSVShouldWork2()
        {
            using (Driver driver = GraphDatabase.driver(GraphDb.boltURI(), Configuration()), Session session = driver.session())
            {
                StatementResult result       = session.run("USING PERIODIC COMMIT " + (_lineCountInCSV + 1) + "\n" + "LOAD CSV FROM \"" + _url + "\" as row fieldterminator \" \"\n" + "MERGE (currentnode:Label1 {uuid:row[0]})\n" + "RETURN currentnode;");
                int             countOfNodes = 0;
                while (result.hasNext())
                {
                    Node node = result.next().get(0).asNode();
                    assertTrue(node.hasLabel("Label1"));
                    assertEquals(countOfNodes.ToString(), node.get("uuid").asString());
                    countOfNodes++;
                }
                assertEquals(_lineCountInCSV, countOfNodes);
            }
        }
Example #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mixingPeriodicCommitAndLoadCSVShouldWorkWithMaps() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MixingPeriodicCommitAndLoadCSVShouldWorkWithMaps()
        {
            using (Driver driver = GraphDatabase.driver(GraphDb.boltURI(), Configuration()), Session session = driver.session())
            {
                StatementResult result       = session.run("USING PERIODIC COMMIT " + (_lineCountInCSV - 1) + "\n" + "LOAD CSV FROM \"" + _url + "\" as row fieldterminator \" \"\n" + "MERGE (currentnode:Label4 {uuid:row[0]})\n" + "RETURN {node:currentnode};");
                int             countOfNodes = 0;
                while (result.hasNext())
                {
                    IEnumerator <KeyValuePair <string, object> > iterator = result.next().get(0).asMap().entrySet().GetEnumerator();
                    while (iterator.MoveNext())
                    {
                        KeyValuePair <string, object> entry = iterator.Current;
                        assertEquals("node", entry.Key);
                        Node node = ( Node )entry.Value;
                        assertTrue(node.hasLabel("Label4"));
                        assertEquals(countOfNodes.ToString(), node.get("uuid").asString());
                        countOfNodes++;
                    }
                }
                assertEquals(_lineCountInCSV, countOfNodes);
            }
        }
Example #5
0
 private void VerifyQueryExecution()
 {
     using (Session session = _driver.session())
     {
         session.readTransaction(tx =>
         {
             StatementResult statementResult = tx.run("MATCH (n) RETURN n.name, n.profession, n.planet, n.city ORDER BY n.name");
             IList <string> fields           = Arrays.asList("n.name", "n.profession", "n.planet", "n.city");
             Record amy = statementResult.next();
             assertEquals(amy.keys(), fields);
             AssertPairs(amy.fields(), "n.name", "Amy", "n.profession", "Student", "n.planet", "Mars", "n.city", "null");
             Record fry = statementResult.next();
             assertEquals(fry.keys(), fields);
             AssertPairs(fry.fields(), "n.name", "Fry", "n.profession", "Delivery Boy", "n.planet", "Earth", "n.city", "New York");
             Record lila = statementResult.next();
             assertEquals(lila.keys(), fields);
             AssertPairs(lila.fields(), "n.name", "Lila", "n.profession", "Pilot", "n.planet", "Earth", "n.city", "New York");
             assertFalse(statementResult.hasNext());
             return(null);
         });
     }
 }
Example #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mixingPeriodicCommitAndLoadCSVShouldWorkWithListsOfLists() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MixingPeriodicCommitAndLoadCSVShouldWorkWithListsOfLists()
        {
            using (Driver driver = GraphDatabase.driver(GraphDb.boltURI(), Configuration()), Session session = driver.session())
            {
                StatementResult result       = session.run("USING PERIODIC COMMIT " + (_lineCountInCSV - 1) + "\n" + "LOAD CSV FROM \"" + _url + "\" as row fieldterminator \" \"\n" + "MERGE (currentnode:Label3 {uuid:row[0]})\n" + "RETURN [[currentnode]];");
                int             countOfNodes = 0;
                while (result.hasNext())
                {
                    IEnumerator <object> iterator = result.next().get(0).asList().GetEnumerator();                             // iterator over outer list
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    assertTrue(iterator.hasNext());
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    iterator = ((IList <object>)iterator.next()).GetEnumerator();                                  // iterator over inner list
                    while (iterator.MoveNext())
                    {
                        Node node = ( Node )iterator.Current;
                        assertTrue(node.hasLabel("Label3"));
                        assertEquals(countOfNodes.ToString(), node.get("uuid").asString());
                        countOfNodes++;
                    }
                }
                assertEquals(_lineCountInCSV, countOfNodes);
            }
        }