test_class.declarator: SMALL_MIN_TTL = Duration.ofMillis(200)
test_class.modifier: private static final
test_class.original_string: private static final Duration SMALL_MIN_TTL = Duration.ofMillis(200);
test_class.type: Duration
test_class.var_name: SMALL_MIN_TTL
test_class.declarator: mockConsulClient = mock(ConsulClient.class)
test_class.modifier: private
test_class.original_string: private ConsulClient mockConsulClient = mock(ConsulClient.class);
test_class.type: ConsulClient
test_class.var_name: mockConsulClient
test_class.declarator: lockProvider = new ConsulLockProvider(mockConsulClient, SMALL_MIN_TTL)
test_class.modifier: private
test_class.original_string: private ConsulLockProvider lockProvider = new ConsulLockProvider(mockConsulClient, SMALL_MIN_TTL);
test_class.type: ConsulLockProvider
test_class.var_name: lockProvider
test_class.file: providers/consul/shedlock-provider-consul/src/test/java/net/javacrumbs/shedlock/provider/consul/ConsulLockProviderTest.java
test_class.identifier: ConsulLockProviderTest
test_case.body: @Test
      void doesNotLockIfLockIsAlreadyObtained() {
          when(mockConsulClient.setKVValue(eq("naruto-leader"), any(), any(PutParams.class)))
              .thenReturn(new Response<>(false, null, null, null));
  
          Optional<SimpleLock> lock = lockProvider.lock(lockConfig("naruto", SMALL_MIN_TTL, SMALL_MIN_TTL.dividedBy(2)));
          assertThat(lock).isEmpty();
      }
test_case.class_method_signature: ConsulLockProviderTest.doesNotLockIfLockIsAlreadyObtained()
test_case.full_signature: @Test void doesNotLockIfLockIsAlreadyObtained()
test_case.identifier: doesNotLockIfLockIsAlreadyObtained
test_case.invocations: thenReturn when setKVValue eq any any lock lockConfig dividedBy isEmpty assertThat
test_case.modifiers: @Test
test_case.parameters: ()
test_case.return: void
test_case.signature: void doesNotLockIfLockIsAlreadyObtained()
focal_class.declarator: logger = LoggerFactory.getLogger(ConsulLockProvider.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(ConsulLockProvider.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: DEFAULT_CONSUL_LOCK_POSTFIX = "-leader"
focal_class.modifier: private static final
focal_class.original_string: private static final String DEFAULT_CONSUL_LOCK_POSTFIX = "-leader";
focal_class.type: String
focal_class.var_name: DEFAULT_CONSUL_LOCK_POSTFIX
focal_class.declarator: DEFAULT_GRACEFUL_SHUTDOWN_INTERVAL = Duration.ofSeconds(2)
focal_class.modifier: private static final
focal_class.original_string: private static final Duration DEFAULT_GRACEFUL_SHUTDOWN_INTERVAL = Duration.ofSeconds(2);
focal_class.type: Duration
focal_class.var_name: DEFAULT_GRACEFUL_SHUTDOWN_INTERVAL
focal_class.declarator: unlockScheduler = Executors.newSingleThreadScheduledExecutor()
focal_class.modifier: private final
focal_class.original_string: private final ScheduledExecutorService unlockScheduler = Executors.newSingleThreadScheduledExecutor();
focal_class.type: ScheduledExecutorService
focal_class.var_name: unlockScheduler
focal_class.declarator: minSessionTtl
focal_class.modifier: private final
focal_class.original_string: private final Duration minSessionTtl;
focal_class.type: Duration
focal_class.var_name: minSessionTtl
focal_class.declarator: consulLockPostfix
focal_class.modifier: private final
focal_class.original_string: private final String consulLockPostfix;
focal_class.type: String
focal_class.var_name: consulLockPostfix
focal_class.declarator: consulClient
focal_class.modifier: private final
focal_class.original_string: private final ConsulClient consulClient;
focal_class.type: ConsulClient
focal_class.var_name: consulClient
focal_class.declarator: gracefulShutdownInterval
focal_class.modifier: private final
focal_class.original_string: private final Duration gracefulShutdownInterval;
focal_class.type: Duration
focal_class.var_name: gracefulShutdownInterval
focal_class.file: providers/consul/shedlock-provider-consul/src/main/java/net/javacrumbs/shedlock/provider/consul/ConsulLockProvider.java
focal_class.identifier: ConsulLockProvider
focal_class.interfaces: implements LockProvider, AutoCloseable
focal_class.class_method_signature: ConsulLockProvider.ConsulLockProvider(ConsulClient consulClient)
focal_class.full_signature: public  ConsulLockProvider(ConsulClient consulClient)
focal_class.identifier: ConsulLockProvider
focal_class.modifiers: public
focal_class.parameters: (ConsulClient consulClient)
focal_class.signature:  ConsulLockProvider(ConsulClient consulClient)
focal_class.class_method_signature: ConsulLockProvider.ConsulLockProvider(ConsulClient consulClient, Duration minSessionTtl)
focal_class.full_signature: public  ConsulLockProvider(ConsulClient consulClient, Duration minSessionTtl)
focal_class.identifier: ConsulLockProvider
focal_class.modifiers: public
focal_class.parameters: (ConsulClient consulClient, Duration minSessionTtl)
focal_class.signature:  ConsulLockProvider(ConsulClient consulClient, Duration minSessionTtl)
focal_class.class_method_signature: ConsulLockProvider.ConsulLockProvider(ConsulClient consulClient, Duration minSessionTtl, String consulLockPostfix, Duration gracefulShutdownInterval)
focal_class.full_signature: public  ConsulLockProvider(ConsulClient consulClient, Duration minSessionTtl, String consulLockPostfix, Duration gracefulShutdownInterval)
focal_class.identifier: ConsulLockProvider
focal_class.modifiers: public
focal_class.parameters: (ConsulClient consulClient, Duration minSessionTtl, String consulLockPostfix, Duration gracefulShutdownInterval)
focal_class.signature:  ConsulLockProvider(ConsulClient consulClient, Duration minSessionTtl, String consulLockPostfix, Duration gracefulShutdownInterval)
focal_class.class_method_signature: ConsulLockProvider.lock(@NonNull LockConfiguration lockConfiguration)
focal_class.full_signature: @Override @NonNull public Optional<SimpleLock> lock(@NonNull LockConfiguration lockConfiguration)
focal_class.identifier: lock
focal_class.modifiers: @Override @NonNull public
focal_class.parameters: (@NonNull LockConfiguration lockConfiguration)
focal_class.return: Optional<SimpleLock>
focal_class.signature: Optional<SimpleLock> lock(@NonNull LockConfiguration lockConfiguration)
focal_class.class_method_signature: ConsulLockProvider.unlock(String sessionId, LockConfiguration lockConfiguration)
focal_class.full_signature:  void unlock(String sessionId, LockConfiguration lockConfiguration)
focal_class.identifier: unlock
focal_class.parameters: (String sessionId, LockConfiguration lockConfiguration)
focal_class.return: void
focal_class.signature: void unlock(String sessionId, LockConfiguration lockConfiguration)
focal_class.class_method_signature: ConsulLockProvider.createSession(LockConfiguration lockConfiguration)
focal_class.full_signature: private String createSession(LockConfiguration lockConfiguration)
focal_class.identifier: createSession
focal_class.modifiers: private
focal_class.parameters: (LockConfiguration lockConfiguration)
focal_class.return: String
focal_class.signature: String createSession(LockConfiguration lockConfiguration)
focal_class.class_method_signature: ConsulLockProvider.tryLock(String sessionId, LockConfiguration lockConfiguration)
focal_class.full_signature: private Optional<SimpleLock> tryLock(String sessionId, LockConfiguration lockConfiguration)
focal_class.identifier: tryLock
focal_class.modifiers: private
focal_class.parameters: (String sessionId, LockConfiguration lockConfiguration)
focal_class.return: Optional<SimpleLock>
focal_class.signature: Optional<SimpleLock> tryLock(String sessionId, LockConfiguration lockConfiguration)
focal_class.class_method_signature: ConsulLockProvider.getLeaderKey(LockConfiguration lockConfiguration)
focal_class.full_signature: private String getLeaderKey(LockConfiguration lockConfiguration)
focal_class.identifier: getLeaderKey
focal_class.modifiers: private
focal_class.parameters: (LockConfiguration lockConfiguration)
focal_class.return: String
focal_class.signature: String getLeaderKey(LockConfiguration lockConfiguration)
focal_class.class_method_signature: ConsulLockProvider.scheduleUnlock(String sessionId, Duration unlockTime)
focal_class.full_signature: private void scheduleUnlock(String sessionId, Duration unlockTime)
focal_class.identifier: scheduleUnlock
focal_class.modifiers: private
focal_class.parameters: (String sessionId, Duration unlockTime)
focal_class.return: void
focal_class.signature: void scheduleUnlock(String sessionId, Duration unlockTime)
focal_class.class_method_signature: ConsulLockProvider.destroy(String sessionId)
focal_class.full_signature: private void destroy(String sessionId)
focal_class.identifier: destroy
focal_class.modifiers: private
focal_class.parameters: (String sessionId)
focal_class.return: void
focal_class.signature: void destroy(String sessionId)
focal_class.class_method_signature: ConsulLockProvider.catchExceptions(Runnable runnable)
focal_class.full_signature: private Runnable catchExceptions(Runnable runnable)
focal_class.identifier: catchExceptions
focal_class.modifiers: private
focal_class.parameters: (Runnable runnable)
focal_class.return: Runnable
focal_class.signature: Runnable catchExceptions(Runnable runnable)
focal_class.class_method_signature: ConsulLockProvider.close()
focal_class.full_signature: @Override public void close()
focal_class.identifier: close
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void close()
focal_method.body: @Override
      @NonNull
      public Optional<SimpleLock> lock(@NonNull LockConfiguration lockConfiguration) {
          String sessionId = createSession(lockConfiguration);
          return tryLock(sessionId, lockConfiguration);
      }
focal_method.class_method_signature: ConsulLockProvider.lock(@NonNull LockConfiguration lockConfiguration)
focal_method.full_signature: @Override @NonNull public Optional<SimpleLock> lock(@NonNull LockConfiguration lockConfiguration)
focal_method.identifier: lock
focal_method.invocations: createSession tryLock
focal_method.modifiers: @Override @NonNull public
focal_method.parameters: (@NonNull LockConfiguration lockConfiguration)
focal_method.return: Optional<SimpleLock>
focal_method.signature: Optional<SimpleLock> lock(@NonNull LockConfiguration lockConfiguration)