Source:
<code>public void indexPersistorTest() throws InterruptedException, IOException, StoreException { Offset indexEndOffset = index.getCurrentEndOffset(); addPutEntries(1, PUT_RECORD_SIZE, Utils.Infinite_Time); Pair<MockId, IndexValue> mockIdIndexValuePair = logOrder.lastEntry().getValue(); index.persistIndex(); metricRegistry = new MetricRegistry(); StoreMetrics metrics = new StoreMetrics(tempDirStr, metricRegistry); StoreConfig config = new StoreConfig(new VerifiableProperties(properties)); index = new PersistentIndex(tempDirStr, scheduler, log, config, STORE_KEY_FACTORY, recovery, hardDelete, metrics, time, UUID.randomUUID()); sessionId = ((StoreFindToken) index.findEntriesSince(new StoreFindToken(), Long.MAX_VALUE).getFindToken()).getSessionId(); assertEquals("Index End offset mismatch ", new Offset(indexEndOffset.getName(), indexEndOffset.getOffset() + PUT_RECORD_SIZE), index.getCurrentEndOffset()); verifyValue(mockIdIndexValuePair.getFirst(), index.findKey(mockIdIndexValuePair.getFirst())); FileSpan fileSpan = new FileSpan(index.getCurrentEndOffset(), new Offset(index.getCurrentEndOffset().getName(), index.getCurrentEndOffset().getOffset() + PUT_RECORD_SIZE)); IndexValue value = new IndexValue(PUT_RECORD_SIZE, fileSpan.getStartOffset(), Utils.Infinite_Time); MockId newId = getUniqueId(); index.addToIndex(new IndexEntry(newId, value), fileSpan); try { index.persistIndex(); fail("Should have thrown exception since index has entries which log does not have"); } catch (StoreException e) { <START> } <END> appendToLog(PUT_RECORD_SIZE); allKeys.put(newId, new Pair<IndexValue, IndexValue>(new IndexValue(PUT_RECORD_SIZE, fileSpan.getStartOffset()), null)); }</code><technical_language>check for right error code</technical_language>

Target:
public void indexPersistorTest() throws InterruptedException, IOException, StoreException { Offset indexEndOffset = index.getCurrentEndOffset(); addPutEntries(1, PUT_RECORD_SIZE, Utils.Infinite_Time); Pair<MockId, IndexValue> mockIdIndexValuePair = logOrder.lastEntry().getValue(); index.persistIndex(); metricRegistry = new MetricRegistry(); StoreMetrics metrics = new StoreMetrics(tempDirStr, metricRegistry); StoreConfig config = new StoreConfig(new VerifiableProperties(properties)); index = new PersistentIndex(tempDirStr, scheduler, log, config, STORE_KEY_FACTORY, recovery, hardDelete, metrics, time, UUID.randomUUID()); sessionId = ((StoreFindToken) index.findEntriesSince(new StoreFindToken(), Long.MAX_VALUE).getFindToken()).getSessionId(); assertEquals("Index End offset mismatch ", new Offset(indexEndOffset.getName(), indexEndOffset.getOffset() + PUT_RECORD_SIZE), index.getCurrentEndOffset()); verifyValue(mockIdIndexValuePair.getFirst(), index.findKey(mockIdIndexValuePair.getFirst())); FileSpan fileSpan = new FileSpan(index.getCurrentEndOffset(), new Offset(index.getCurrentEndOffset().getName(), index.getCurrentEndOffset().getOffset() + PUT_RECORD_SIZE)); IndexValue value = new IndexValue(PUT_RECORD_SIZE, fileSpan.getStartOffset(), Utils.Infinite_Time); MockId newId = getUniqueId(); index.addToIndex(new IndexEntry(newId, value), fileSpan); try { index.persistIndex(); fail("Should have thrown exception since index has entries which log does not have"); } catch (StoreException e) { assertEquals("StoreException error code mismatch ", StoreErrorCodes.Illegal_Index_State, e.getErrorCode()); } appendToLog(PUT_RECORD_SIZE); }