@Test public void test_bad_trylock() { Lock good = LockTestUtils.goodLock(null); Lock bad = LockTestUtils.badLock(null); Lock good2 = LockTestUtils.goodLock(null); MultiLock multiLock = new MultiLock(null, good, bad, good2); assertTrue(!multiLock.tryLock()); verify(good, times(1)).tryLock(); verify(bad, times(1)).tryLock(); verify(good2, times(0)).tryLock(); }
@Override public boolean tryLock() { for (Lock lock : locks) { if (!lock.tryLock()) return false; } return true; }
MultiLock implements Lock { @Override public boolean tryLock() { for (Lock lock : locks) { if (!lock.tryLock()) return false; } return true; } }
MultiLock implements Lock { @Override public boolean tryLock() { for (Lock lock : locks) { if (!lock.tryLock()) return false; } return true; } MultiLock(MultiLockDefinition def, Lock... locks);  MultiLock(MultiLockDefinition def, LockProvider provider); }
MultiLock implements Lock { @Override public boolean tryLock() { for (Lock lock : locks) { if (!lock.tryLock()) return false; } return true; } 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 boolean tryLock() { for (Lock lock : locks) { if (!lock.tryLock()) return false; } return true; } MultiLock(MultiLockDefinition def, Lock... locks);  MultiLock(MultiLockDefinition def, LockProvider provider); Lock[] getLocks(); @Override boolean tryLock(); @Override void lock(); @Override void unlock(); @Override LockDefinition getLockDefinition();  }