public override void Perform(long nodeId, string value) { Node node = _db.getNodeById(nodeId); Label label = Label.label(value); if (node.HasLabel(label)) { node.RemoveLabel(label); } else { node.AddLabel(label); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldIdentifyTransactionWithNetZeroChangesAsReadOnly() public virtual void ShouldIdentifyTransactionWithNetZeroChangesAsReadOnly() { // GIVEN a transaction that has seen some changes, where all those changes result in a net 0 change set // a good way of producing such state is to add a label to an existing node, and then remove it. GraphDatabaseAPI db = Dbr.GraphDatabaseAPI; TransactionIdStore txIdStore = Db.DependencyResolver.resolveDependency(typeof(TransactionIdStore)); long startTxId = txIdStore.LastCommittedTransactionId; Node node = CreateEmptyNode(db); using (Transaction tx = Db.beginTx()) { node.AddLabel(TestLabels.LABEL_ONE); node.RemoveLabel(TestLabels.LABEL_ONE); tx.Success(); } // WHEN closing that transaction // THEN it should not have been committed assertEquals("Expected last txId to be what it started at + 2 (1 for the empty node, and one for the label)", startTxId + 2, txIdStore.LastCommittedTransactionId); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldDetectNoChangesInCommitsAlsoForTheIndexes() public virtual void ShouldDetectNoChangesInCommitsAlsoForTheIndexes() { // GIVEN a transaction that has seen some changes, where all those changes result in a net 0 change set // a good way of producing such state is to add a label to an existing node, and then remove it. GraphDatabaseAPI db = Dbr.GraphDatabaseAPI; TransactionIdStore txIdStore = Db.DependencyResolver.resolveDependency(typeof(TransactionIdStore)); long startTxId = txIdStore.LastCommittedTransactionId; Node node = CreateEmptyNode(db); Index <Node> index = CreateNodeIndex(db); using (Transaction tx = Db.beginTx()) { node.AddLabel(TestLabels.LABEL_ONE); node.RemoveLabel(TestLabels.LABEL_ONE); index.Add(node, "key", "value"); index.Remove(node, "key", "value"); tx.Success(); } // WHEN closing that transaction // THEN it should not have been committed assertEquals("Expected last txId to be what it started at + 3 " + "(1 for the empty node, 1 for index, and one for the label)", startTxId + 3, txIdStore.LastCommittedTransactionId); }