//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private org.neo4j.function.ThrowingFunction<org.neo4j.kernel.impl.transaction.log.LogPosition,org.neo4j.kernel.impl.transaction.log.TransactionCursor,java.io.IOException> log(int... transactionCounts) throws java.io.IOException private ThrowingFunction <LogPosition, TransactionCursor, IOException> Log(params int[] transactionCounts) { long baseOffset = LogPosition.start(0).ByteOffset; //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") org.neo4j.function.ThrowingFunction<org.neo4j.kernel.impl.transaction.log.LogPosition,org.neo4j.kernel.impl.transaction.log.TransactionCursor,java.io.IOException> result = mock(org.neo4j.function.ThrowingFunction.class); ThrowingFunction <LogPosition, TransactionCursor, IOException> result = mock(typeof(ThrowingFunction)); AtomicLong txId = new AtomicLong(0); CommittedTransactionRepresentation[][] logs = new CommittedTransactionRepresentation[transactionCounts.Length][]; for (int logVersion = 0; logVersion < transactionCounts.Length; logVersion++) { logs[logVersion] = Transactions(transactionCounts[logVersion], txId); } when(result.Apply(any(typeof(LogPosition)))).thenAnswer(invocation => { LogPosition position = invocation.getArgument(0); if (position == null) { // A mockito issue when calling the "when" methods, I believe return(null); } // For simplicity the offset means, in this test, the array offset CommittedTransactionRepresentation[] transactions = logs[toIntExact(position.LogVersion)]; CommittedTransactionRepresentation[] subset = copyOfRange(transactions, toIntExact(position.ByteOffset - baseOffset), transactions.Length); ArrayUtil.reverse(subset); return(given(subset)); }); return(result); }
private int MapToken(ThrowingFunction <Token, int, KernelException> f) { try { using (Transaction tx = beginTransaction()) { return(f.Apply(tx.Token())); } } catch (KernelException e) { fail("Unwanted exception: " + e.Message); return(-1); // unreachable } }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: //ORIGINAL LINE: private static <FROM, TO, EX extends Exception> java.util.concurrent.Callable<TO> task(final org.neo4j.function.ThrowingFunction<FROM,TO,EX> function, String name, final FROM parameter, final org.neo4j.function.FailableConsumer<Thread> threadConsumer) private static Callable <TO> Task <FROM, TO, EX>(ThrowingFunction <FROM, TO, EX> function, string name, FROM parameter, FailableConsumer <Thread> threadConsumer) where EX : Exception { return(() => { Thread thread = Thread.CurrentThread; string previousName = thread.Name; thread.Name = name; threadConsumer.accept(thread); try { return function.Apply(parameter); } catch (Exception failure) { threadConsumer.Fail(failure); throw failure; } finally { thread.Name = previousName; } }); }