static void dissectNewLeadershipTerm(
        final MutableDirectBuffer buffer, final int offset, final StringBuilder builder)
    {
        int absoluteOffset = offset;
        absoluteOffset += dissectLogHeader(CONTEXT, NEW_LEADERSHIP_TERM, buffer, absoluteOffset, builder);

        final long logLeadershipTermId = buffer.getLong(absoluteOffset, LITTLE_ENDIAN);
        absoluteOffset += SIZE_OF_LONG;

        final long nextLeadershipTermId = buffer.getLong(absoluteOffset, LITTLE_ENDIAN);
        absoluteOffset += SIZE_OF_LONG;

        final long nextTermBaseLogPosition = buffer.getLong(absoluteOffset, LITTLE_ENDIAN);
        absoluteOffset += SIZE_OF_LONG;

        final long nextLogPosition = buffer.getLong(absoluteOffset, LITTLE_ENDIAN);
        absoluteOffset += SIZE_OF_LONG;

        final long leadershipTermId = buffer.getLong(absoluteOffset, LITTLE_ENDIAN);
        absoluteOffset += SIZE_OF_LONG;

        final long termBaseLogPosition = buffer.getLong(absoluteOffset, LITTLE_ENDIAN);
        absoluteOffset += SIZE_OF_LONG;

        final long logPosition = buffer.getLong(absoluteOffset, LITTLE_ENDIAN);
        absoluteOffset += SIZE_OF_LONG;

        final long leaderRecordingId = buffer.getLong(absoluteOffset, LITTLE_ENDIAN);
        absoluteOffset += SIZE_OF_LONG;

        final long timestamp = buffer.getLong(absoluteOffset, LITTLE_ENDIAN);
        absoluteOffset += SIZE_OF_LONG;

        final int memberId = buffer.getInt(absoluteOffset, LITTLE_ENDIAN);
        absoluteOffset += SIZE_OF_INT;

        final int leaderId = buffer.getInt(absoluteOffset, LITTLE_ENDIAN);
        absoluteOffset += SIZE_OF_INT;

        final int logSessionId = buffer.getInt(absoluteOffset, LITTLE_ENDIAN);
        absoluteOffset += SIZE_OF_INT;

        final int appVersion = buffer.getInt(absoluteOffset, LITTLE_ENDIAN);
        absoluteOffset += SIZE_OF_INT;

        final boolean isStartup = 1 == buffer.getByte(absoluteOffset);

        builder.append(": memberId=").append(memberId)
            .append(" logLeadershipTermId=").append(logLeadershipTermId)
            .append(" nextLeadershipTermId=").append(nextLeadershipTermId)
            .append(" nextTermBaseLogPosition=").append(nextTermBaseLogPosition)
            .append(" nextLogPosition=").append(nextLogPosition)
            .append(" leadershipTermId=").append(leadershipTermId)
            .append(" termBaseLogPosition=").append(termBaseLogPosition)
            .append(" logPosition=").append(logPosition)
            .append(" leaderRecordingId=").append(leaderRecordingId)
            .append(" timestamp=").append(timestamp)
            .append(" leaderId=").append(leaderId)
            .append(" logSessionId=").append(logSessionId)
            .append(" appVersion=");
        appendSemanticVersion(appVersion, builder);
        builder.append(" isStartup=").append(isStartup);
    }
@Test
    void dissectNewLeadershipTerm()
    {
        internalEncodeLogHeader(buffer, 0, 8, 9, () -> 33_000_000_000L);
        buffer.putLong(LOG_HEADER_LENGTH, 1, LITTLE_ENDIAN);
        buffer.putLong(LOG_HEADER_LENGTH + SIZE_OF_LONG, 2, LITTLE_ENDIAN);
        buffer.putLong(LOG_HEADER_LENGTH + (SIZE_OF_LONG * 2), 3, LITTLE_ENDIAN);
        buffer.putLong(LOG_HEADER_LENGTH + (SIZE_OF_LONG * 3), 13, LITTLE_ENDIAN);
        buffer.putLong(LOG_HEADER_LENGTH + (SIZE_OF_LONG * 4), 23, LITTLE_ENDIAN);
        buffer.putLong(LOG_HEADER_LENGTH + (SIZE_OF_LONG * 5), 4, LITTLE_ENDIAN);
        buffer.putLong(LOG_HEADER_LENGTH + (SIZE_OF_LONG * 6), 5, LITTLE_ENDIAN);
        buffer.putLong(LOG_HEADER_LENGTH + (SIZE_OF_LONG * 7), 6, LITTLE_ENDIAN);
        buffer.putLong(LOG_HEADER_LENGTH + (SIZE_OF_LONG * 8), 7, LITTLE_ENDIAN);
        buffer.putInt(LOG_HEADER_LENGTH + (SIZE_OF_LONG * 9), 13, LITTLE_ENDIAN);
        buffer.putInt(LOG_HEADER_LENGTH + (SIZE_OF_LONG * 9) + SIZE_OF_INT, 100, LITTLE_ENDIAN);
        buffer.putInt(LOG_HEADER_LENGTH + (SIZE_OF_LONG * 9) + SIZE_OF_INT * 2, 200, LITTLE_ENDIAN);
        buffer.putInt(LOG_HEADER_LENGTH + (SIZE_OF_LONG * 9) + SIZE_OF_INT * 3, 300, LITTLE_ENDIAN);
        buffer.putByte(LOG_HEADER_LENGTH + (SIZE_OF_LONG * 9) + SIZE_OF_INT * 4, (byte)1);

        ClusterEventDissector.dissectNewLeadershipTerm(buffer, 0, builder);

        assertEquals("[33.000000000] " + CONTEXT + ": " + NEW_LEADERSHIP_TERM.name() + " [8/9]: memberId=13 " +
            "logLeadershipTermId=1 nextLeadershipTermId=2 nextTermBaseLogPosition=3 nextLogPosition=13 " +
            "leadershipTermId=23 termBaseLogPosition=4 logPosition=5 leaderRecordingId=6 " +
            "timestamp=7 leaderId=100 logSessionId=200 appVersion=0.1.44 isStartup=true",
            builder.toString());
    }