Source:
<code>public void testDifferentTriggers() throws Exception { properties.setProperty("store.enable.compaction", Boolean.toString(true)); blobStore.details = generateRandomCompactionDetails(2); <START> properties.setProperty("store.compaction.triggers", "Time"); <END> Runnable timeTriggerCode = () -> { 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); }; Runnable adminTriggerCode = () -> assertFalse("Compaction should not be scheduled", compactionManager.scheduleNextForCompaction(blobStore)); doTestTrigger(Arrays.asList(timeTriggerCode, adminTriggerCode)); properties.setProperty("store.compaction.triggers", "Admin"); long startTimeMs = time.milliseconds(); adminTriggerCode = () -> { 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); }; timeTriggerCode = () -> assertEquals("Time should not have moved forward", startTimeMs, time.milliseconds()); doTestTrigger(Arrays.asList(adminTriggerCode, timeTriggerCode)); }</code><technical_language>good tests 1) triggers enabled 2) of enabled</technical_language>

Target:
public void testDifferentTriggers() throws Exception { blobStore.details = generateRandomCompactionDetails(2); Runnable adminDisabledChecker = () -> assertFalse("Compaction should not be scheduled", compactionManager.scheduleNextForCompaction(blobStore)); properties.setProperty("store.compaction.triggers", ""); AtomicLong startTimeMs = new AtomicLong(time.milliseconds()); Runnable periodicDisabledChecker = () -> assertEquals("Time should not have moved forward", startTimeMs.get(), time.milliseconds()); doTestTrigger(Arrays.asList(adminDisabledChecker, periodicDisabledChecker)); 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)); 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)); }