@Test
  public void constructionErrorCasesTest() {
    UUID sessionId = UUID.randomUUID();
    UUID incarnationId = UUID.randomUUID();
    LogSegmentName logSegmentName = LogSegmentName.generateFirstSegmentName(isLogSegmented);
    Offset offset = new Offset(logSegmentName, 0);
    MockId key = new MockId(TestUtils.getRandomString(10));
    MockId resetKey = new MockId(TestUtils.getRandomString(10));
    PersistentIndex.IndexEntryType resetKeyType =
        PersistentIndex.IndexEntryType.values()[(new Random()).nextInt(PersistentIndex.IndexEntryType.values().length)];
    short resetKeyVersion = (short) random.nextInt(5);

    // no offset
    testConstructionFailure(key, sessionId, incarnationId, null);
    // no session id
    testConstructionFailure(key, null, incarnationId, offset);
    // no incarnation Id
    testConstructionFailure(key, sessionId, null, offset);

    // no key in IndexBased
    try {
      new StoreFindToken(null, offset, sessionId, null, null, null, UNINITIALIZED_RESET_KEY_VERSION);
      fail("Construction of StoreFindToken should have failed");
    } catch (IllegalArgumentException e) {
      // expected. Nothing to do.
    }

    // version 3 token without reset key or reset key type
    for (FindTokenType type : EnumSet.of(FindTokenType.JournalBased, FindTokenType.IndexBased)) {
      for (Pair<MockId, PersistentIndex.IndexEntryType> pair : Arrays.asList(
          new Pair<MockId, PersistentIndex.IndexEntryType>(resetKey, null),
          new Pair<MockId, PersistentIndex.IndexEntryType>(null, resetKeyType))) {
        try {
          new StoreFindToken(type, offset, key, sessionId, incarnationId, type == FindTokenType.JournalBased, VERSION_3,
              pair.getFirst(), pair.getSecond(), resetKeyVersion);
          fail("Construction of StoreFindToken should have failed because rest key or its type is null.");
        } catch (IllegalArgumentException e) {
          // expected
        }
      }
    }
  }
Tests {@link StoreFindToken} for construction error cases.
ambry-store/src/test/java/com/github/ambry/store/StoreFindTokenTest.java