### Question:
KernelTransactionImplementationHandle implements KernelTransactionHandle { @Override public boolean markForTermination( Status reason ) { return tx.markForTermination( txReuseCount, reason ); } KernelTransactionImplementationHandle( KernelTransactionImplementation tx, SystemNanoClock clock ); @Override long lastTransactionIdWhenStarted(); @Override long lastTransactionTimestampWhenStarted(); @Override long startTime(); @Override long startTimeNanos(); @Override long timeoutMillis(); @Override boolean isOpen(); @Override boolean markForTermination( Status reason ); @Override AuthSubject subject(); @Override Map<String,Object> getMetaData(); @Override Optional<Status> terminationReason(); @Override boolean isUnderlyingTransaction( KernelTransaction tx ); @Override long getUserTransactionId(); @Override String getUserTransactionName(); @Override Stream<ExecutingQuery> executingQueries(); @Override Stream<? extends ActiveLock> activeLocks(); @Override TransactionExecutionStatistic transactionStatistic(); @Override boolean isSchemaTransaction(); @Override boolean equals( Object o ); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void markForTerminationCallsKernelTransactionImplementation() { int reuseCount = 42; Status.Transaction terminationReason = Status.Transaction.Terminated; KernelTransactionImplementation tx = mock( KernelTransactionImplementation.class ); when( tx.getReuseCount() ).thenReturn( reuseCount ); KernelTransactionImplementationHandle handle = new KernelTransactionImplementationHandle( tx, clock ); handle.markForTermination( terminationReason ); verify( tx ).markForTermination( reuseCount, terminationReason ); }
@Test public void markForTerminationReturnsTrueWhenSuccessful() { KernelTransactionImplementation tx = mock( KernelTransactionImplementation.class ); when( tx.getReuseCount() ).thenReturn( 42 ); when( tx.markForTermination( anyLong(), any() ) ).thenReturn( true ); KernelTransactionImplementationHandle handle = new KernelTransactionImplementationHandle( tx, clock ); assertTrue( handle.markForTermination( Status.Transaction.Terminated ) ); }
@Test public void markForTerminationReturnsFalseWhenNotSuccessful() { KernelTransactionImplementation tx = mock( KernelTransactionImplementation.class ); when( tx.getReuseCount() ).thenReturn( 42 ); when( tx.markForTermination( anyLong(), any() ) ).thenReturn( false ); KernelTransactionImplementationHandle handle = new KernelTransactionImplementationHandle( tx, clock ); assertFalse( handle.markForTermination( Status.Transaction.Terminated ) ); }