Search in sources :

Example 11 with TransactionImpl

use of org.neo4j.kernel.impl.coreapi.TransactionImpl in project neo4j by neo4j.

the class TransactionImplTest method shouldThrowTransientExceptionOnTransientKernelException.

@Test
void shouldThrowTransientExceptionOnTransientKernelException() throws Exception {
    // GIVEN
    KernelTransaction kernelTransaction = mock(KernelTransaction.class);
    when(kernelTransaction.isOpen()).thenReturn(true);
    doThrow(new TransactionFailureException(Status.Transaction.ConstraintsChanged, "Proving that transaction does the right thing")).when(kernelTransaction).close();
    TransactionImpl transaction = new TransactionImpl(tokenHolders, contextFactory, availabilityGuard, engine, kernelTransaction, null, null);
    // WHEN
    transaction.commit();
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) TransactionFailureException(org.neo4j.internal.kernel.api.exceptions.TransactionFailureException) TransactionImpl(org.neo4j.kernel.impl.coreapi.TransactionImpl) Test(org.junit.jupiter.api.Test)

Example 12 with TransactionImpl

use of org.neo4j.kernel.impl.coreapi.TransactionImpl in project neo4j by neo4j.

the class TransactionImplTest method checkForIAE.

private void checkForIAE(Consumer<Transaction> consumer, String message) {
    KernelTransaction kernelTransaction = mock(KernelTransaction.class);
    when(kernelTransaction.tokenRead()).thenReturn(mock(TokenRead.class));
    try (TransactionImpl tx = new TransactionImpl(tokenHolders, contextFactory, availabilityGuard, engine, kernelTransaction, null, null)) {
        assertThatThrownBy(() -> consumer.accept(tx)).isInstanceOf(IllegalArgumentException.class).hasMessageContaining(message);
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) TransactionImpl(org.neo4j.kernel.impl.coreapi.TransactionImpl) TokenRead(org.neo4j.internal.kernel.api.TokenRead)

Aggregations

TransactionImpl (org.neo4j.kernel.impl.coreapi.TransactionImpl)12 Test (org.junit.jupiter.api.Test)8 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)8 Barrier (org.neo4j.test.Barrier)4 OtherThreadExecutor (org.neo4j.test.OtherThreadExecutor)4 Status (org.neo4j.kernel.api.exceptions.Status)2 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)2 MutableLong (org.apache.commons.lang3.mutable.MutableLong)1 TransactionTerminatedException (org.neo4j.graphdb.TransactionTerminatedException)1 TransientFailureException (org.neo4j.graphdb.TransientFailureException)1 TokenRead (org.neo4j.internal.kernel.api.TokenRead)1 TransactionFailureException (org.neo4j.internal.kernel.api.exceptions.TransactionFailureException)1