@Test
  public void testDifferentTriggers() {
    blobStore.details = generateRandomCompactionDetails(2);
    Runnable adminDisabledChecker =
        () -> assertFalse("Compaction should not be scheduled", compactionManager.scheduleNextForCompaction(blobStore));

    // 1. all enabled is already tested in testCompactionExecutorHappyPath()

    // 2. none enabled
    properties.setProperty("store.compaction.triggers", "");
    AtomicLong startTimeMs = new AtomicLong(time.milliseconds());
    // the fact that the time based trigger has not been enabled can only be tested indirectly by making sure
    // time has not moved forward
    Runnable periodicDisabledChecker =
        () -> assertEquals("Time should not have moved forward", startTimeMs.get(), time.milliseconds());
    doTestTrigger(Arrays.asList(adminDisabledChecker, periodicDisabledChecker));

    // 3. only periodic enabled
    properties.setProperty("store.compaction.triggers", "Periodic");
    Runnable periodicEnabledChecker = () -> {
      try {
        assertTrue("Compaction calls did not come within the expected time",
            blobStore.compactCallsCountdown.await(1, TimeUnit.SECONDS));
      } catch (InterruptedException e) {
        throw new IllegalStateException(e);
      }
      if (blobStore.callOrderException != null) {
        throw new IllegalStateException(blobStore.callOrderException);
      }
      assertTrue("compact() should have been called", blobStore.compactCalled);
    };
    doTestTrigger(Arrays.asList(adminDisabledChecker, periodicEnabledChecker));

    // 4. only admin enabled
    properties.setProperty("store.compaction.triggers", "Admin");
    startTimeMs.set(time.milliseconds());
    Runnable adminEnabledChecker = () -> {
      assertTrue("Compaction should be scheduled", compactionManager.scheduleNextForCompaction(blobStore));
      try {
        assertTrue("Compaction calls did not come within the expected time",
            blobStore.compactCallsCountdown.await(1, TimeUnit.SECONDS));
      } catch (InterruptedException e) {
        throw new IllegalStateException(e);
      }
      if (blobStore.callOrderException != null) {
        throw new IllegalStateException(blobStore.callOrderException);
      }
      assertTrue("compact() should have been called", blobStore.compactCalled);
    };
    periodicDisabledChecker =
        () -> assertEquals("Time should not have moved forward", startTimeMs.get(), time.milliseconds());
    doTestTrigger(Arrays.asList(adminEnabledChecker, periodicDisabledChecker));
  }
Tests for cases where only certain triggers are enabled.
ambry-store/src/test/java/com/github/ambry/store/CompactionManagerTest.java