//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void getNodesWithLabelsWithTxAddsAndRemoves() public virtual void getNodesWithLabelsWithTxAddsAndRemoves() { // GIVEN GraphDatabaseService beansAPI = DbRule.GraphDatabaseAPI; Node node1 = CreateNode(beansAPI, Labels.MyLabel, Labels.MyOtherLabel); Node node2 = CreateNode(beansAPI, Labels.MyLabel, Labels.MyOtherLabel); // WHEN Node node3; ISet <Node> nodesWithMyLabel; ISet <Node> nodesWithMyOtherLabel; using (Transaction tx = beansAPI.BeginTx()) { node3 = beansAPI.CreateNode(Labels.MyLabel); node2.RemoveLabel(Labels.MyLabel); // extracted here to be asserted below nodesWithMyLabel = asSet(beansAPI.FindNodes(Labels.MyLabel)); nodesWithMyOtherLabel = asSet(beansAPI.FindNodes(Labels.MyOtherLabel)); tx.Success(); } // THEN assertEquals(asSet(node1, node3), nodesWithMyLabel); assertEquals(asSet(node1, node2), nodesWithMyOtherLabel); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void createPointArrayPropertyOnLatestDatabase() internal virtual void CreatePointArrayPropertyOnLatestDatabase() { File storeDir = _testDirectory.storeDir(); Label pointNode = Label.label("PointNode"); string propertyKey = "a"; PointValue pointValue = pointValue(Cartesian, 1.0, 2.0); GraphDatabaseService database = startDatabaseWithFormat(storeDir, Standard.LATEST_NAME); using (Transaction transaction = database.BeginTx()) { Node node = database.CreateNode(pointNode); node.SetProperty(propertyKey, new PointValue[] { pointValue, pointValue }); transaction.Success(); } database.Shutdown(); GraphDatabaseService restartedDatabase = startDatabaseWithFormat(storeDir, Standard.LATEST_NAME); using (Transaction ignored = restartedDatabase.BeginTx()) { using (ResourceIterator <Node> nodes = restartedDatabase.FindNodes(pointNode)) { //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: Node node = nodes.next(); PointValue[] points = ( PointValue[] )node.GetProperty(propertyKey); assertThat(points, arrayWithSize(2)); } } restartedDatabase.Shutdown(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRetrieveMultipleNodesWithSameValueFromIndex() public virtual void ShouldRetrieveMultipleNodesWithSameValueFromIndex() { // this test was included here for now as a precondition for the following test // given GraphDatabaseService graph = DbRule.GraphDatabaseAPI; Neo4jMatchers.createIndex(graph, _label1, "name"); Node node1; Node node2; using (Transaction tx = graph.BeginTx()) { node1 = graph.CreateNode(_label1); node1.SetProperty("name", "Stefan"); node2 = graph.CreateNode(_label1); node2.SetProperty("name", "Stefan"); tx.Success(); } using (Transaction tx = graph.BeginTx()) { ResourceIterator <Node> result = graph.FindNodes(_label1, "name", "Stefan"); assertEquals(asSet(node1, node2), asSet(result)); tx.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void createDateArrayOnLatestDatabase() internal virtual void CreateDateArrayOnLatestDatabase() { File storeDir = _testDirectory.storeDir(); Label label = Label.label("DateNode"); string propertyKey = "a"; LocalDate date = DateValue.date(1991, 5, 3).asObjectCopy(); GraphDatabaseService database = startDatabaseWithFormat(storeDir, Standard.LATEST_NAME); using (Transaction transaction = database.BeginTx()) { Node node = database.CreateNode(label); node.SetProperty(propertyKey, new LocalDate[] { date, date }); transaction.Success(); } database.Shutdown(); GraphDatabaseService restartedDatabase = startDatabaseWithFormat(storeDir, Standard.LATEST_NAME); using (Transaction ignored = restartedDatabase.BeginTx()) { using (ResourceIterator <Node> nodes = restartedDatabase.FindNodes(label)) { //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: Node node = nodes.next(); LocalDate[] points = ( LocalDate[] )node.GetProperty(propertyKey); assertThat(points, arrayWithSize(2)); } } restartedDatabase.Shutdown(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void createdNodeShouldShowUpInIndexQuery() public virtual void CreatedNodeShouldShowUpInIndexQuery() { // GIVEN GraphDatabaseService beansAPI = DbRule.GraphDatabaseAPI; Neo4jMatchers.createIndex(beansAPI, _label1, "name"); CreateNode(beansAPI, map("name", "Mattias"), _label1); // WHEN Transaction tx = beansAPI.BeginTx(); long sizeBeforeDelete = count(beansAPI.FindNodes(_label1, "name", "Mattias")); CreateNode(beansAPI, map("name", "Mattias"), _label1); long sizeAfterDelete = count(beansAPI.FindNodes(_label1, "name", "Mattias")); tx.Close(); // THEN assertThat(sizeBeforeDelete, equalTo(1L)); assertThat(sizeAfterDelete, equalTo(2L)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotThrowConcurrentModificationExceptionWhenUpdatingWhileIterating() public virtual void ShouldNotThrowConcurrentModificationExceptionWhenUpdatingWhileIterating() { // given GraphDatabaseService graph = DbRule.GraphDatabaseAPI; Label label = Label.label("Bird"); Node node1; Node node2; Node node3; using (Transaction tx = graph.BeginTx()) { node1 = graph.CreateNode(label); node2 = graph.CreateNode(label); tx.Success(); } // when ISet <Node> result = new HashSet <Node>(); using (Transaction tx = graph.BeginTx()) { node3 = graph.CreateNode(label); ResourceIterator <Node> iterator = graph.FindNodes(label); node3.RemoveLabel(label); graph.CreateNode(label); while (iterator.MoveNext()) { result.Add(iterator.Current); } tx.Success(); } // then does not throw and retains view from iterator creation time assertEquals(asSet(node1, node2, node3), result); }