//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRollbackOnFailureInBeforeCommit() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldRollbackOnFailureInBeforeCommit() { // Given TransactionHook hook = mock(typeof(TransactionHook)); const string message = "Original"; when(hook.beforeCommit(any(typeof(ReadableTransactionState)), any(typeof(KernelTransaction)), any(typeof(StorageReader)))).thenReturn(new TransactionHook_OutcomeAnonymousInnerClass(this, message)); InternalKernel().registerTransactionHook(hook); // When Write ops = DataWriteInNewTransaction(); ops.NodeCreate(); try { Commit(); fail("Expected this to fail."); } catch (TransactionFailureException e) { assertThat(e.Status(), equalTo(Org.Neo4j.Kernel.Api.Exceptions.Status_Transaction.TransactionHookFailed)); assertThat(e.InnerException.Message, equalTo(message)); } // Then verify(hook).beforeCommit(any(typeof(ReadableTransactionState)), any(typeof(KernelTransaction)), any(typeof(StorageReader))); verify(hook).afterRollback(any(typeof(ReadableTransactionState)), any(typeof(KernelTransaction)), any(typeof(Org.Neo4j.Kernel.api.TransactionHook_Outcome))); verifyNoMoreInteractions(hook); }
public virtual void Add(TransactionHook hook, TransactionHook_Outcome outcome) { HooksWithAttachment.Add(Pair.of(hook, outcome)); if (outcome != null && !outcome.Successful) { FailureConflict = outcome.Failure(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") public void afterCommit(org.neo4j.storageengine.api.txstate.ReadableTransactionState state, org.neo4j.kernel.api.KernelTransaction tx, TransactionHooksState hooksState) public virtual void AfterCommit(ReadableTransactionState state, KernelTransaction tx, TransactionHooksState hooksState) { if (hooksState == null) { return; } foreach (Pair <TransactionHook, TransactionHook_Outcome> hookAndOutcome in hooksState.HooksWithOutcome()) { TransactionHook hook = hookAndOutcome.First(); TransactionHook_Outcome outcome = hookAndOutcome.Other(); hook.afterCommit(state, tx, outcome); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReceiveTxStateOnCommit() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReceiveTxStateOnCommit() { // Given TransactionHook hook = mock(typeof(TransactionHook)); InternalKernel().registerTransactionHook(hook); // When Write ops = DataWriteInNewTransaction(); ops.NodeCreate(); Commit(); // Then verify(hook).beforeCommit(any(typeof(ReadableTransactionState)), any(typeof(KernelTransaction)), any(typeof(StorageReader))); verify(hook).afterCommit(any(typeof(ReadableTransactionState)), any(typeof(KernelTransaction)), any()); verifyNoMoreInteractions(hook); }
public override void RegisterTransactionHook( TransactionHook hook ) { _hooks.register( hook ); }
public virtual void Unregister(TransactionHook hook) { Hooks.remove(hook); }
public virtual void Register(TransactionHook hook) { Hooks.Add(hook); }