コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testNotFoundException()
        public virtual void TestNotFoundException()
        {
            Node         node1  = _graph.createNode();
            Node         node2  = _graph.createNode();
            Relationship rel    = node1.CreateRelationshipTo(node2, MyRelTypes.TEST);
            long         nodeId = node1.Id;
            long         relId  = rel.Id;

            rel.Delete();
            node2.Delete();
            node1.Delete();
            NewTransaction();
            try
            {
                _graph.getNodeById(nodeId);
                fail("Get node by id on deleted node should throw exception");
            }
            catch (NotFoundException)
            {               // good
            }
            try
            {
                _graph.getRelationshipById(relId);
                fail("Get relationship by id on deleted node should " + "throw exception");
            }
            catch (NotFoundException)
            {               // good
            }

            // Finally
            Rollback();
        }
コード例 #2
0
ファイル: CountsComputerTest.cs プロジェクト: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCreateACountsStoreWhenThereAreUnusedNodeRecordsInTheDB()
        public virtual void ShouldCreateACountsStoreWhenThereAreUnusedNodeRecordsInTheDB()
        {
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("deprecation") final org.neo4j.kernel.internal.GraphDatabaseAPI db = (org.neo4j.kernel.internal.GraphDatabaseAPI) dbBuilder.newGraphDatabase();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
            GraphDatabaseAPI db = ( GraphDatabaseAPI )_dbBuilder.newGraphDatabase();

            using (Transaction tx = Db.beginTx())
            {
                Db.createNode(Label.label("A"));
                Db.createNode(Label.label("C"));
                Node node = Db.createNode(Label.label("D"));
                Db.createNode();
                node.Delete();
                tx.Success();
            }
            long lastCommittedTransactionId = GetLastTxId(db);

            Db.shutdown();

            RebuildCounts(lastCommittedTransactionId);

            using (Lifespan life = new Lifespan())
            {
                CountsTracker store = life.Add(CreateCountsTracker());
                assertEquals(BASE_TX_ID + 1 + 1 + 1 + 1, store.TxId());
                assertEquals(3, store.TotalEntriesStored());
                assertEquals(3, Get(store, nodeKey(-1)));
                assertEquals(1, Get(store, nodeKey(0)));
                assertEquals(1, Get(store, nodeKey(1)));
                assertEquals(0, Get(store, nodeKey(2)));
                assertEquals(0, Get(store, nodeKey(3)));
            }
        }
コード例 #3
0
 internal virtual long DeleteNeighbours(Node node, RelationshipType relType)
 {
     try
     {
         long deleted = 0;
         foreach (Relationship rel in node.Relationships)
         {
             Node other = rel.GetOtherNode(node);
             rel.Delete();
             other.Delete();
             deleted++;
         }
         return(deleted);
     }
     catch (NotFoundException)
     {
         // Procedures should internally handle missing nodes due to lazy interactions
         return(0);
     }
 }
コード例 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testNotInTransactionException()
        public virtual void TestNotInTransactionException()
        {
            Node node1 = _graph.createNode();

            node1.SetProperty("test", 1);
            Node         node2 = _graph.createNode();
            Node         node3 = _graph.createNode();
            Relationship rel   = node1.CreateRelationshipTo(node2, MyRelTypes.TEST);

            rel.SetProperty("test", 11);
            Commit();
            try
            {
                _graph.createNode();
                fail("Create node with no transaction should throw exception");
            }
            catch (NotInTransactionException)
            {               // good
            }
            try
            {
                node1.CreateRelationshipTo(node2, MyRelTypes.TEST);
                fail("Create relationship with no transaction should " + "throw exception");
            }
            catch (NotInTransactionException)
            {               // good
            }
            try
            {
                node1.SetProperty("test", 2);
                fail("Set property with no transaction should throw exception");
            }
            catch (NotInTransactionException)
            {               // good
            }
            try
            {
                rel.SetProperty("test", 22);
                fail("Set property with no transaction should throw exception");
            }
            catch (NotInTransactionException)
            {               // good
            }
            try
            {
                node3.Delete();
                fail("Delete node with no transaction should " + "throw exception");
            }
            catch (NotInTransactionException)
            {               // good
            }
            try
            {
                rel.Delete();
                fail("Delete relationship with no transaction should " + "throw exception");
            }
            catch (NotInTransactionException)
            {               // good
            }
            NewTransaction();
            assertEquals(node1.GetProperty("test"), 1);
            assertEquals(rel.GetProperty("test"), 11);
            assertEquals(rel, node1.GetSingleRelationship(MyRelTypes.TEST, Direction.OUTGOING));
            node1.Delete();
            node2.Delete();
            rel.Delete();
            node3.Delete();

            // Finally
            Rollback();
        }