public static void extendActiveLock(Duration lockAtMostFor, Duration lockAtLeastFor) {
        SimpleLock lock = locks().peekLast();
        if (lock == null) throw new NoActiveLockException();
        Optional<SimpleLock> newLock = lock.extend(lockAtMostFor, lockAtLeastFor);
        if (newLock.isPresent()) {
            // removing and adding here should be safe as it's a thread local variable and
            // the changes are
            // only visible in the current thread.
            locks().removeLast();
            locks().addLast(newLock.get());
        } else {
            throw new LockCanNotBeExtendedException();
        }
    }
@Test
    void shouldExtendNestedLock() {
        LockConfiguration innerConfiguration = new LockConfiguration(Instant.now(), "test2", ofSeconds(1), ZERO);
        SimpleLock innerLock = mock(SimpleLock.class);
        when(lockProvider.lock(innerConfiguration)).thenReturn(Optional.of(innerLock));
        when(innerLock.extend(extendBy, ZERO)).thenReturn(Optional.of(newLock));

        Runnable innerTask = () -> LockExtender.extendActiveLock(extendBy, ZERO);
        Runnable outerTask = () -> executor.executeWithLock(innerTask, innerConfiguration);
        executor.executeWithLock(outerTask, configuration);

        verify(innerLock).extend(extendBy, ZERO);
    }