@Test public void test_bad_lock() { Lock good = LockTestUtils.goodLock(null); Lock bad = LockTestUtils.badLock(null); Lock good2 = LockTestUtils.goodLock(null); try { MultiLock multiLock = new MultiLock(null, good, bad, good2); multiLock.lock(); fail(); } catch (FailedToAcquireLockException e) { } verify(good, times(1)).lock(); verify(bad, times(1)).lock(); verify(good2, times(0)).lock(); }
@Override public void lock() throws FailedToAcquireLockException { for (Lock lock : locks) { lock.lock(); } }
MultiLock implements Lock { @Override public void lock() throws FailedToAcquireLockException { for (Lock lock : locks) { lock.lock(); } } }
MultiLock implements Lock { @Override public void lock() throws FailedToAcquireLockException { for (Lock lock : locks) { lock.lock(); } } MultiLock(MultiLockDefinition def, Lock... locks);  MultiLock(MultiLockDefinition def, LockProvider provider); }
MultiLock implements Lock { @Override public void lock() throws FailedToAcquireLockException { for (Lock lock : locks) { lock.lock(); } } MultiLock(MultiLockDefinition def, Lock... locks);  MultiLock(MultiLockDefinition def, LockProvider provider); Lock[] getLocks(); @Override boolean tryLock(); @Override void lock(); @Override void unlock(); @Override LockDefinition getLockDefinition(); }
MultiLock implements Lock { @Override public void lock() throws FailedToAcquireLockException { for (Lock lock : locks) { lock.lock(); } } MultiLock(MultiLockDefinition def, Lock... locks);  MultiLock(MultiLockDefinition def, LockProvider provider); Lock[] getLocks(); @Override boolean tryLock(); @Override void lock(); @Override void unlock(); @Override LockDefinition getLockDefinition();  }