Search in sources :

Example 6 with TestKernelTransactionHandle

use of org.neo4j.kernel.impl.api.TestKernelTransactionHandle in project neo4j by neo4j.

the class TransactionDependenciesResolverTest method detectBlockedTransactionsBySharedLock.

@Test
void detectBlockedTransactionsBySharedLock() {
    HashMap<KernelTransactionHandle, Optional<QuerySnapshot>> map = new HashMap<>();
    TestKernelTransactionHandle handle1 = new TestKernelTransactionHandleWithLocks(new StubKernelTransaction(), 0, singletonList(new ActiveLock(ResourceTypes.NODE, SHARED, 1, 1)));
    TestKernelTransactionHandle handle2 = new TestKernelTransactionHandleWithLocks(new StubKernelTransaction());
    map.put(handle1, Optional.of(createQuerySnapshot(1)));
    map.put(handle2, Optional.of(createQuerySnapshotWaitingForLock(2, EXCLUSIVE, ResourceTypes.NODE, 1, 1)));
    TransactionDependenciesResolver resolver = new TransactionDependenciesResolver(map);
    assertFalse(resolver.isBlocked(handle1));
    assertTrue(resolver.isBlocked(handle2));
}
Also used : ActiveLock(org.neo4j.lock.ActiveLock) Optional(java.util.Optional) HashMap(java.util.HashMap) TestKernelTransactionHandle(org.neo4j.kernel.impl.api.TestKernelTransactionHandle) TestKernelTransactionHandle(org.neo4j.kernel.impl.api.TestKernelTransactionHandle) KernelTransactionHandle(org.neo4j.kernel.api.KernelTransactionHandle) Test(org.junit.jupiter.api.Test)

Aggregations

HashMap (java.util.HashMap)6 Optional (java.util.Optional)6 Test (org.junit.jupiter.api.Test)6 KernelTransactionHandle (org.neo4j.kernel.api.KernelTransactionHandle)6 TestKernelTransactionHandle (org.neo4j.kernel.impl.api.TestKernelTransactionHandle)6 ActiveLock (org.neo4j.lock.ActiveLock)4