//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testGetDirectedRelationship() public virtual void TestGetDirectedRelationship() { Node node1 = GraphDb.getNodeById(_node1Id); Relationship rel = node1.GetSingleRelationship(MyRelTypes.TEST, Direction.OUTGOING); assertEquals(_int1, rel.GetProperty(_key1)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testAddProperty() public virtual void TestAddProperty() { string key3 = "key3"; Node node1 = GraphDb.getNodeById(_node1Id); Node node2 = GraphDb.getNodeById(_node2Id); Relationship rel = node1.GetSingleRelationship(MyRelTypes.TEST, Direction.BOTH); // add new property node2.SetProperty(key3, _int1); rel.SetProperty(key3, _int2); assertTrue(node1.HasProperty(_key1)); assertTrue(node2.HasProperty(_key1)); assertTrue(node1.HasProperty(_key2)); assertTrue(node2.HasProperty(_key2)); assertTrue(node1.HasProperty(_arrayKey)); assertTrue(node2.HasProperty(_arrayKey)); assertTrue(rel.HasProperty(_arrayKey)); assertTrue(!node1.HasProperty(key3)); assertTrue(node2.HasProperty(key3)); assertEquals(_int1, node1.GetProperty(_key1)); assertEquals(_int2, node2.GetProperty(_key1)); assertEquals(_string1, node1.GetProperty(_key2)); assertEquals(_string2, node2.GetProperty(_key2)); assertEquals(_int1, rel.GetProperty(_key1)); assertEquals(_string1, rel.GetProperty(_key2)); assertEquals(_int2, rel.GetProperty(key3)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @After public void deleteTestingGraph() public virtual void DeleteTestingGraph() { Node node1 = GraphDb.getNodeById(_node1Id); Node node2 = GraphDb.getNodeById(_node2Id); node1.GetSingleRelationship(MyRelTypes.TEST, Direction.BOTH).delete(); node1.Delete(); node2.Delete(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testNodeGetProperties() public virtual void TestNodeGetProperties() { Node node1 = GraphDb.getNodeById(_node1Id); assertTrue(!node1.HasProperty(null)); IEnumerator <string> keys = node1.PropertyKeys.GetEnumerator(); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: keys.next(); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: keys.next(); assertTrue(node1.HasProperty(_key1)); assertTrue(node1.HasProperty(_key2)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testNodeChangeProperty() public virtual void TestNodeChangeProperty() { Node node1 = GraphDb.getNodeById(_node1Id); Node node2 = GraphDb.getNodeById(_node2Id); Relationship rel = node1.GetSingleRelationship(MyRelTypes.TEST, Direction.BOTH); // test change property node1.SetProperty(_key1, _int2); node2.SetProperty(_key1, _int1); rel.SetProperty(_key1, _int2); int[] newIntArray = new int[] { 3, 2, 1 }; node1.SetProperty(_arrayKey, newIntArray); node2.SetProperty(_arrayKey, newIntArray); rel.SetProperty(_arrayKey, newIntArray); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testNodeRemoveProperty() public virtual void TestNodeRemoveProperty() { Node node1 = GraphDb.getNodeById(_node1Id); Node node2 = GraphDb.getNodeById(_node2Id); Relationship rel = node1.GetSingleRelationship(MyRelTypes.TEST, Direction.BOTH); // test remove property assertEquals(1, node1.RemoveProperty(_key1)); assertEquals(2, node2.RemoveProperty(_key1)); assertEquals(1, rel.RemoveProperty(_key1)); assertEquals(_string1, node1.RemoveProperty(_key2)); assertEquals(_string2, node2.RemoveProperty(_key2)); assertEquals(_string1, rel.RemoveProperty(_key2)); assertNotNull(node1.RemoveProperty(_arrayKey)); assertNotNull(node2.RemoveProperty(_arrayKey)); assertNotNull(rel.RemoveProperty(_arrayKey)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testCreateRelationshipWithCommits() public virtual void TestCreateRelationshipWithCommits() // throws NotFoundException { Node n1 = GraphDb.createNode(); NewTransaction(); n1 = GraphDb.getNodeById(n1.Id); Node n2 = GraphDb.createNode(); n1.CreateRelationshipTo(n2, TEST); NewTransaction(); Relationship[] relArray = GetRelationshipArray(n1.Relationships); assertEquals(1, relArray.Length); relArray = GetRelationshipArray(n1.Relationships); relArray[0].Delete(); n1.Delete(); n2.Delete(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testNodeCreateAndDelete() public virtual void TestNodeCreateAndDelete() { Node node = GraphDb.createNode(); long nodeId = node.Id; GraphDb.getNodeById(nodeId); node.Delete(); Tx.success(); Tx.begin(); try { GraphDb.getNodeById(nodeId); fail("Node[" + nodeId + "] should be deleted."); } catch (NotFoundException) { } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testDirectedRelationship1() public virtual void TestDirectedRelationship1() { Node node1 = GraphDb.getNodeById(_node1Id); Relationship rel = node1.GetSingleRelationship(MyRelTypes.TEST, Direction.BOTH); Node[] nodes = rel.Nodes; assertEquals(2, nodes.Length); Node node2 = GraphDb.getNodeById(_node2Id); assertTrue(nodes[0].Equals(node1) && nodes[1].Equals(node2)); assertEquals(node1, rel.StartNode); assertEquals(node2, rel.EndNode); Relationship[] relArray = GetRelationshipArray(node1.GetRelationships(MyRelTypes.TEST, Direction.OUTGOING)); assertEquals(1, relArray.Length); assertEquals(rel, relArray[0]); relArray = GetRelationshipArray(node2.GetRelationships(MyRelTypes.TEST, Direction.INCOMING)); assertEquals(1, relArray.Length); assertEquals(rel, relArray[0]); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testAddCacheCleared() public virtual void TestAddCacheCleared() { Node nodeA = GraphDb.createNode(); nodeA.SetProperty("1", 1); Node nodeB = GraphDb.createNode(); Relationship rel = nodeA.CreateRelationshipTo(nodeB, MyRelTypes.TEST); rel.SetProperty("1", 1); Commit(); NewTransaction(); nodeA.CreateRelationshipTo(nodeB, MyRelTypes.TEST); int count = 0; foreach (Relationship relToB in nodeA.GetRelationships(MyRelTypes.TEST)) { count++; } assertEquals(2, count); nodeA.SetProperty("2", 2); assertEquals(1, nodeA.GetProperty("1")); rel.SetProperty("2", 2); assertEquals(1, rel.GetProperty("1")); // trigger empty load GraphDb.getNodeById(nodeA.Id); GraphDb.getRelationshipById(rel.Id); // apply COW maps Commit(); NewTransaction(); count = 0; foreach (Relationship relToB in nodeA.GetRelationships(MyRelTypes.TEST)) { count++; } assertEquals(2, count); assertEquals(1, nodeA.GetProperty("1")); assertEquals(1, rel.GetProperty("1")); assertEquals(2, nodeA.GetProperty("2")); assertEquals(2, rel.GetProperty("2")); }
protected internal virtual Node GetNode(long id) { return(GraphDb.getNodeById(id)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testIllegalPropertyType() public virtual void TestIllegalPropertyType() { Node node1 = GraphDb.createNode(); try { node1.SetProperty(_key, new object()); fail("Shouldn't validate"); } catch (Exception) { // good } { Transaction tx = Transaction; tx.Failure(); tx.Close(); } Transaction = GraphDb.beginTx(); try { GraphDb.getNodeById(node1.Id); fail("Node should not exist, previous tx didn't rollback"); } catch (NotFoundException) { // good } node1 = GraphDb.createNode(); Node node2 = GraphDb.createNode(); Relationship rel = node1.CreateRelationshipTo(node2, MyRelTypes.TEST); try { rel.SetProperty(_key, new object()); fail("Shouldn't validate"); } catch (Exception) { // good } try { Transaction tx = Transaction; tx.Success(); tx.Close(); fail("Shouldn't validate"); } catch (Exception) { // good } Transaction = GraphDb.beginTx(); try { GraphDb.getNodeById(node1.Id); fail("Node should not exist, previous tx didn't rollback"); } catch (NotFoundException) { // good } try { GraphDb.getNodeById(node2.Id); fail("Node should not exist, previous tx didn't rollback"); } catch (NotFoundException) { // good } }