@Test
public void toStringSharedPageLockTrackerTest() throws Exception {

    SharedPageLockTracker pageLockTracker = new SharedPageLockTracker();
    pageLockTracker.onReadLock(1, 2, 3, 4);
    pageLockTracker.onReadUnlock(1, 2, 3, 4);
    Thread asyncLockUnlock = new Thread(() -> {
        pageLockTracker.onReadLock(4, 32, 1, 64);
    }, "async-lock-unlock");
    asyncLockUnlock.start();
    asyncLockUnlock.join();
    long threadIdInLog = asyncLockUnlock.getId();
    SharedPageLockTrackerDump pageLockDump = pageLockTracker.dump();
    // Hack to have same timestamp in test.
    for (ThreadPageLockState state : pageLockDump.threadPageLockStates)
        GridTestUtils.setFieldValue(state.pageLockDump, PageLockDump.class, "time", TIME);
    assertNotNull(pageLockDump);
    String dumpStr = ToStringDumpHelper.toStringDump(pageLockDump);
    String expectedLog = "Page locks dump:" + U.nl() +
        U.nl() +
        "Thread=[name=async-lock-unlock, id=" + threadIdInLog + "], state=TERMINATED" + U.nl() +
        "Locked pages = [32[0000000000000020](r=1|w=0)]" + U.nl() +
        "Locked pages log: name=async-lock-unlock time=(1596173397167, " +
        ToStringDumpHelper.DATE_FMT.format(new java.util.Date(TIME)) + ")" + U.nl() +
        "L=1 -> Read lock pageId=32, structureId=null [pageIdHex=0000000000000020, partId=0, pageIdx=32, flags=00000000]" + U.nl() +
        U.nl() +
        U.nl() +
        U.nl();
    assertEquals(expectedLog, dumpStr);
}