Source:
private void verifyReadFromFile(NavigableMap<MockId, NavigableSet<IndexValue>> referenceIndex, File file, Offset startOffset, int numItems, int expectedSizeWritten, long endOffset, long lastModifiedTimeInMs, Pair<StoreKey, PersistentIndex.IndexEntryType> resetKey) throws IOException, StoreException { Journal journal = new Journal(tempDir.getAbsolutePath(), Integer.MAX_VALUE, Integer.MAX_VALUE); IndexSegment fromDisk = createIndexSegmentFromFile(file, false, journal); verifyAllForIndexSegmentFromFile(referenceIndex, fromDisk, startOffset, numItems, expectedSizeWritten, false, endOffset, lastModifiedTimeInMs, resetKey); verifyJournal(referenceIndex, journal); fromDisk.map(true); journal = new Journal(tempDir.getAbsolutePath(), Integer.MAX_VALUE, Integer.MAX_VALUE); fromDisk = createIndexSegmentFromFile(file, true, journal); verifyAllForIndexSegmentFromFile(referenceIndex, fromDisk, startOffset, numItems, expectedSizeWritten, true, endOffset, lastModifiedTimeInMs, resetKey); assertNull("Journal should not have any entries", journal.getFirstOffset()); File BloomFile = new File(file.getParent(), IndexSegment.generateIndexSegmentFilenamePrefix(startOffset) + BLOOM_FILE_NAME_SUFFIX); BloomFile.delete(); journal = new Journal(tempDir.getAbsolutePath(), Integer.MAX_VALUE, Integer.MAX_VALUE); fromDisk = createIndexSegmentFromFile(file, true, journal); verifyAllForIndexSegmentFromFile(referenceIndex, fromDisk, startOffset, numItems, expectedSizeWritten, true, endOffset, lastModifiedTimeInMs, resetKey); assertNull("Journal should not have any entries", journal.getFirstOffset()); }

Target:
private void verifyReadFromFile(NavigableMap<MockId, NavigableSet<IndexValue>> referenceIndex, File file, Offset startOffset, int numItems, int expectedSizeWritten, long endOffset, long lastModifiedTimeInMs, Pair<StoreKey, PersistentIndex.IndexEntryType> resetKey) throws IOException, StoreException { Journal journal = new Journal(tempDir.getAbsolutePath(), Integer.MAX_VALUE, Integer.MAX_VALUE); IndexSegment fromDisk = createIndexSegmentFromFile(file, false, journal); verifyAllForIndexSegmentFromFile(referenceIndex, fromDisk, startOffset, numItems, expectedSizeWritten, false, endOffset, lastModifiedTimeInMs, resetKey); verifyJournal(referenceIndex, journal); fromDisk.map(true); journal = new Journal(tempDir.getAbsolutePath(), Integer.MAX_VALUE, Integer.MAX_VALUE); fromDisk = createIndexSegmentFromFile(file, true, journal); verifyAllForIndexSegmentFromFile(referenceIndex, fromDisk, startOffset, numItems, expectedSizeWritten, true, endOffset, lastModifiedTimeInMs, resetKey); assertNull("Journal should not have any entries", journal.getFirstOffset()); File bloomFile = new File(file.getParent(), IndexSegment.generateIndexSegmentFilenamePrefix(startOffset) + IndexSegment.BLOOM_FILE_NAME_SUFFIX); assertTrue("File could not be deleted", bloomFile.delete()); assertFalse("Bloom file should not exist", bloomFile.exists()); journal = new Journal(tempDir.getAbsolutePath(), Integer.MAX_VALUE, Integer.MAX_VALUE); fromDisk = createIndexSegmentFromFile(file, true, journal); assertTrue("Bloom file does not exist", bloomFile.exists()); verifyAllForIndexSegmentFromFile(referenceIndex, fromDisk, startOffset, numItems, expectedSizeWritten, true, endOffset, lastModifiedTimeInMs, resetKey); assertNull("Journal should not have any entries", journal.getFirstOffset()); }