### Question:
TransactionDependenciesResolver { public boolean isBlocked( KernelTransactionHandle handle ) { return directDependencies.get( handle ) != null; } TransactionDependenciesResolver( Map<KernelTransactionHandle,List<QuerySnapshot>> handleSnapshotsMap ); boolean isBlocked( KernelTransactionHandle handle ); String describeBlockingTransactions( KernelTransactionHandle handle  ); Map<String,Object> describeBlockingLocks( KernelTransactionHandle handle );  }### Answer:
@Test public void detectIndependentTransactionsAsNotBlocked() { HashMap<KernelTransactionHandle,List<QuerySnapshot>> map = new HashMap<>(); TestKernelTransactionHandle handle1 = new TestKernelTransactionHandleWithLocks( new StubKernelTransaction() ); TestKernelTransactionHandle handle2 = new TestKernelTransactionHandleWithLocks( new StubKernelTransaction() ); map.put( handle1, singletonList( createQuerySnapshot( 1 ) ) ); map.put( handle2, singletonList( createQuerySnapshot( 2 ) ) ); TransactionDependenciesResolver resolver = new TransactionDependenciesResolver( map ); assertFalse( resolver.isBlocked( handle1 ) ); assertFalse( resolver.isBlocked( handle2 ) ); }
@Test public void detectBlockedTransactionsByExclusiveLock() { HashMap<KernelTransactionHandle,List<QuerySnapshot>> map = new HashMap<>(); TestKernelTransactionHandle handle1 = new TestKernelTransactionHandleWithLocks( new StubKernelTransaction(), 0, singletonList( ActiveLock.exclusiveLock( ResourceTypes.NODE, 1 ) ) ); TestKernelTransactionHandle handle2 = new TestKernelTransactionHandleWithLocks( new StubKernelTransaction() ); map.put( handle1, singletonList( createQuerySnapshot( 1 ) ) ); map.put( handle2, singletonList( createQuerySnapshotWaitingForLock( 2, false, ResourceTypes.NODE, 1 ) ) ); TransactionDependenciesResolver resolver = new TransactionDependenciesResolver( map ); assertFalse( resolver.isBlocked( handle1 ) ); assertTrue( resolver.isBlocked( handle2 ) ); }
@Test public void detectBlockedTransactionsBySharedLock() { HashMap<KernelTransactionHandle,List<QuerySnapshot>> map = new HashMap<>(); TestKernelTransactionHandle handle1 = new TestKernelTransactionHandleWithLocks( new StubKernelTransaction(), 0, singletonList( ActiveLock.sharedLock( ResourceTypes.NODE, 1 ) ) ); TestKernelTransactionHandle handle2 = new TestKernelTransactionHandleWithLocks( new StubKernelTransaction() ); map.put( handle1, singletonList( createQuerySnapshot( 1 ) ) ); map.put( handle2, singletonList( createQuerySnapshotWaitingForLock( 2, true, ResourceTypes.NODE, 1 ) ) ); TransactionDependenciesResolver resolver = new TransactionDependenciesResolver( map ); assertFalse( resolver.isBlocked( handle1 ) ); assertTrue( resolver.isBlocked( handle2 ) ); }