@Theory public void shouldNotAcquireCellLockIfDoesNotLockAtCellLevel(ConflictHandler conflictHandler) { Assume.assumeFalse(conflictHandler.lockCellsForConflicts()); PreCommitCondition canAcquireCellLock = (ignored) -> { LockResponse response = acquireCellLock(ROW, COLUMN); //current lock implementation allows you to get a cell lock on a row that is already locked assertTrue(response.wasSuccessful()); }; commitWriteWith(canAcquireCellLock, conflictHandler); }
@Theory public void shouldAcquireCellLockIfLocksAtCellLevel(ConflictHandler conflictHandler) { Assume.assumeTrue(conflictHandler.lockCellsForConflicts()); PreCommitCondition cellLocksAcquired = (ignored) -> { LockResponse response = acquireCellLock(ROW, COLUMN); assertFalse(response.wasSuccessful()); }; commitWriteWith(cellLocksAcquired, conflictHandler); }
@Theory public void canAcquireLockOnMultipleCellsOnSameRow(ConflictHandler conflictHandler) { Assume.assumeTrue(conflictHandler.lockCellsForConflicts()); PreCommitCondition canAcquireLockOnDifferentCell = (ignored) -> { LockResponse response = acquireCellLock(ROW, OTHER_COLUMN); assertTrue(response.wasSuccessful()); }; commitWriteWith(canAcquireLockOnDifferentCell, conflictHandler); }
@Theory public void shouldAcquireRowAndCellLockIfRequiresBoth(ConflictHandler conflictHandler) { Assume.assumeTrue(conflictHandler.lockCellsForConflicts() && conflictHandler.lockRowsForConflicts()); PreCommitCondition cellAndRowLockAcquired = (ignored) -> { LockResponse cellLockResponse = acquireCellLock(ROW, COLUMN); LockResponse rowLockResponse = acquireRowLock(ROW); assertFalse(cellLockResponse.wasSuccessful()); assertFalse(rowLockResponse.wasSuccessful()); }; commitWriteWith(cellAndRowLockAcquired, conflictHandler); }
if (conflictHandler.lockCellsForConflicts()) { for (Cell cell : getLocalWrites(tableRef).keySet()) { result.add(
@Theory public void shouldAcquireCellLockIfLocksAtCellLevel(ConflictHandler conflictHandler) { Assume.assumeTrue(conflictHandler.lockCellsForConflicts()); PreCommitCondition cellLocksAcquired = (ignored) -> { LockResponse response = acquireCellLock(ROW, COLUMN); assertFalse(response.wasSuccessful()); }; commitWriteWith(cellLocksAcquired, conflictHandler); }
@Theory public void canAcquireLockOnMultipleCellsOnSameRow(ConflictHandler conflictHandler) { Assume.assumeTrue(conflictHandler.lockCellsForConflicts()); PreCommitCondition canAcquireLockOnDifferentCell = (ignored) -> { LockResponse response = acquireCellLock(ROW, OTHER_COLUMN); assertTrue(response.wasSuccessful()); }; commitWriteWith(canAcquireLockOnDifferentCell, conflictHandler); }
@Theory public void shouldNotAcquireCellLockIfDoesNotLockAtCellLevel(ConflictHandler conflictHandler) { Assume.assumeFalse(conflictHandler.lockCellsForConflicts()); PreCommitCondition canAcquireCellLock = (ignored) -> { LockResponse response = acquireCellLock(ROW, COLUMN); //current lock implementation allows you to get a cell lock on a row that is already locked assertTrue(response.wasSuccessful()); }; commitWriteWith(canAcquireCellLock, conflictHandler); }
if (conflictHandler.lockCellsForConflicts()) { for (Cell cell : getLocalWrites(tableRef).keySet()) { result.add(
@Theory public void shouldAcquireRowAndCellLockIfRequiresBoth(ConflictHandler conflictHandler) { Assume.assumeTrue(conflictHandler.lockCellsForConflicts() && conflictHandler.lockRowsForConflicts()); PreCommitCondition cellAndRowLockAcquired = (ignored) -> { LockResponse cellLockResponse = acquireCellLock(ROW, COLUMN); LockResponse rowLockResponse = acquireRowLock(ROW); assertFalse(cellLockResponse.wasSuccessful()); assertFalse(rowLockResponse.wasSuccessful()); }; commitWriteWith(cellAndRowLockAcquired, conflictHandler); }