internal virtual long CreateRelationshipWithProperty(long firstNodeId, long secondNodeId, string propertyKey, object propertyValue) { Node first = Db.getNodeById(firstNodeId); Node second = Db.getNodeById(secondNodeId); Relationship relationship = first.CreateRelationshipTo(second, Reltype); relationship.SetProperty(propertyKey, propertyValue); return(relationship.Id); }
private Node GetNodeById(long id) { using (Transaction ignored = DbRule.beginTx()) { return(DbRule.getNodeById(id)); } }
/* * Tests for a particular bug with dense nodes. It used to be that if a dense node had relationships * for only one direction, if a request for relationships of the other direction was made, no relationships * would be returned, ever. */ //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void givenDenseNodeWhenAskForWrongDirectionThenIncorrectNrOfRelsReturned() public virtual void GivenDenseNodeWhenAskForWrongDirectionThenIncorrectNrOfRelsReturned() { // Given //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int denseNodeThreshold = int.Parse(org.neo4j.graphdb.factory.GraphDatabaseSettings.dense_node_threshold.getDefaultValue()) + 1; int denseNodeThreshold = int.Parse(GraphDatabaseSettings.dense_node_threshold.DefaultValue) + 1; Node node1; using (Transaction tx = Db.beginTx()) { node1 = Db.createNode(); Node node2 = Db.createNode(); for (int i = 0; i < denseNodeThreshold; i++) { node1.CreateRelationshipTo(node2, RelationshipType.withName("FOO")); } tx.Success(); } // When/Then using (Transaction ignored = Db.beginTx()) { Node node1b = Db.getNodeById(node1.Id); IEnumerable <Relationship> rels = node1b.GetRelationships(Direction.INCOMING); assertEquals(0, Iterables.count(rels)); IEnumerable <Relationship> rels2 = node1b.GetRelationships(Direction.OUTGOING); assertEquals(denseNodeThreshold, Iterables.count(rels2)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(timeout = 30_000) public void terminateExpiredTransaction() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void TerminateExpiredTransaction() { using (Transaction transaction = Database.beginTx()) { Database.createNode(); transaction.Success(); } ExpectedException.expectMessage("The transaction has been terminated."); using (Transaction transaction = Database.beginTx()) { Node nodeById = Database.getNodeById(NODE_ID); nodeById.SetProperty("a", "b"); _executor.submit(StartAnotherTransaction()).get(); } }