### Question:
LockGroup implements AutoCloseable { public final void add( Lock lock ) { if ( lock == null ) { throw new IllegalArgumentException( "Cannot add null locks. See LockService.NOLOCK instead." ); } locks.add( lock ); }  final void add( Lock lock ); @Override void close();  }### Answer:
@Test public void shouldReleaseAllLocksWhenExitingTheLockGroupRegion() { Lock lock1 = mock( Lock.class ); Lock lock2 = mock( Lock.class ); Lock lock3 = mock( Lock.class ); try ( LockGroup locks = new LockGroup() ) { locks.add( lock1 ); locks.add( lock2 ); locks.add( lock3 ); } verify( lock1, times( 1 ) ).release(); verify( lock2, times( 1 ) ).release(); verify( lock3, times( 1 ) ).release(); }