@Test
  public void testJournalBootstrapMode() {
    LogSegmentName logSegmentName = StoreTestUtils.getRandomLogSegmentName(null);
    Offset[] offsets = new Offset[4];
    MockId[] keys = new MockId[4];
    for (int i = 0; i < 4; i++) {
      offsets[i] = new Offset(logSegmentName, i * 1000);
      keys[i] = new MockId("id" + i);
    }
    List<JournalEntry> journalEntries = new ArrayList<>();
    // Bootstrap mode is off by default and journal entries should respect the max constraint
    Journal journal = new Journal("test", 1, 1);
    addEntryAndVerify(journal, offsets[0], keys[0], journalEntries);
    addEntryAndVerify(journal, offsets[1], keys[1], journalEntries);
    Assert.assertEquals("Unexpected journal size", 1, journal.getCurrentNumberOfEntries());
    Assert.assertEquals("Oldest entry is not being replaced", offsets[1], journal.getFirstOffset());
    Assert.assertEquals("Entries in journal not expected", journalEntries, journal.getAllEntries());
    // Bootstrap mode is turned on and journal entries should be able to exceed the max constraint
    journal.startBootstrap();
    addEntryAndVerify(journal, offsets[2], keys[2], journalEntries);
    Assert.assertEquals("Unexpected journal size", 2, journal.getCurrentNumberOfEntries());
    Assert.assertEquals("Oldest entry should not be replaced", offsets[1], journal.getFirstOffset());
    Assert.assertEquals("Entries in journal not expected", journalEntries, journal.getAllEntries());
    // Bootstrap mode is off and journal entries should respect the max constraint again
    journal.finishBootstrap();
    addEntryAndVerify(journal, offsets[3], keys[3], journalEntries);
    Assert.assertEquals("Unexpected journal size", 2, journal.getCurrentNumberOfEntries());
    Assert.assertEquals("Oldest entry is not being replaced", offsets[2], journal.getFirstOffset());
    Assert.assertEquals("Entries in journal not expected", journalEntries, journal.getAllEntries());
  }
Tests the {@link Journal}'s bootstrap mode by performing the following operations:
1. Add entries before going into bootstrap mode and the entries in the journal should respect the max constraint
2. Start bootstrap mode and add more entries. Verify the entries in the journal can exceed the max constraint
3. Finish bootstrap mode and verify the entries in the journal are respecting the max constraint again
ambry-store/src/test/java/com/github/ambry/store/JournalTest.java