@Test
  public void testExtendDeferralTimerDelaysHandler() throws InterruptedException {
    // Arrange
    AtomicBoolean handlerCalled = new AtomicBoolean(false);
    BootstrapSession session = new BootstrapSession(mockPartitionId, "snapshot1", "node1",
        diskManagerConfig, (nodeId, partitionId) -> handlerCalled.set(true), (nodeId, partitionId) -> handlerCalled.set(true));
    session.start();

    // Sleep less than the original delay (300 ms)
    Thread.sleep(250);

    // Act
    // Extend the deferral timer
    session.extendDeferralTimer(500);

    // Wait long enough to exceed original delay, but not the extended delay
    // If Extend functionality is not working, this will trigger the handler as we have waited 350ms (250 + 100)
    // after starting the session and this is more than the default timer of 300ms.
    Thread.sleep(100);

    // Assert
    // Should not have triggered yet
    assertFalse(handlerCalled.get());

    // Wait more to exceed the extended delay
    // We have waited 600ms (100 + 250) after extending the session and this is more than the extended timer of 500ms.
    Thread.sleep(500);

    assertTrue(handlerCalled.get());
  }
Test that the default timer can be extended and that it delays the handler.
ambry-store/src/test/java/com/github/ambry/store/BootstrapSessionTest.java