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

        final long candidateTermId = buffer.getLong(absoluteOffset, LITTLE_ENDIAN);
        absoluteOffset += SIZE_OF_LONG;
        final long leadershipTermId = buffer.getLong(absoluteOffset, LITTLE_ENDIAN);
        absoluteOffset += SIZE_OF_LONG;
        final long logPosition = buffer.getLong(absoluteOffset, LITTLE_ENDIAN);
        absoluteOffset += SIZE_OF_LONG;
        final long logLeadershipTermId = buffer.getLong(absoluteOffset, LITTLE_ENDIAN);
        absoluteOffset += SIZE_OF_LONG;
        final long appendPosition = buffer.getLong(absoluteOffset, LITTLE_ENDIAN);
        absoluteOffset += SIZE_OF_LONG;
        final long catchupPosition = 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;

        builder.append(": memberId=").append(memberId).append(' ');
        absoluteOffset += SIZE_OF_INT + buffer.getStringAscii(absoluteOffset, builder);

        builder.append(" leaderId=").append(leaderId);
        builder.append(" candidateTermId=").append(candidateTermId);
        builder.append(" leadershipTermId=").append(leadershipTermId);
        builder.append(" logPosition=").append(logPosition);
        builder.append(" logLeadershipTermId=").append(logLeadershipTermId);
        builder.append(" appendPosition=").append(appendPosition);
        builder.append(" catchupPosition=").append(catchupPosition);
        builder.append(" reason=");
        buffer.getStringAscii(absoluteOffset, builder);
    }
@Test
    void dissectElectionStateChange()
    {
        final int offset = 10;
        int writeIndex = offset;
        writeIndex += internalEncodeLogHeader(buffer, offset, 100, 200, () -> 5_000_000_000L);
        buffer.putLong(writeIndex, 101010, LITTLE_ENDIAN);
        writeIndex += SIZE_OF_LONG;
        buffer.putLong(writeIndex, 6, LITTLE_ENDIAN);
        writeIndex += SIZE_OF_LONG;
        buffer.putLong(writeIndex, 1024, LITTLE_ENDIAN);
        writeIndex += SIZE_OF_LONG;
        buffer.putLong(writeIndex, 2, LITTLE_ENDIAN);
        writeIndex += SIZE_OF_LONG;
        buffer.putLong(writeIndex, 1218, LITTLE_ENDIAN);
        writeIndex += SIZE_OF_LONG;
        buffer.putLong(writeIndex, 800, LITTLE_ENDIAN);
        writeIndex += SIZE_OF_LONG;
        buffer.putInt(writeIndex, 86, LITTLE_ENDIAN);
        writeIndex += SIZE_OF_INT;
        buffer.putInt(writeIndex, 3, LITTLE_ENDIAN);
        writeIndex += SIZE_OF_INT;
        writeIndex += buffer.putStringAscii(writeIndex, "old -> new");
        buffer.putStringAscii(writeIndex, "this is a test");

        ClusterEventDissector.dissectElectionStateChange(buffer, offset, builder);

        assertEquals("[5.000000000] " + CONTEXT + ": " + ELECTION_STATE_CHANGE.name() + " [100/200]: memberId=86" +
            " old -> new leaderId=3 candidateTermId=101010 leadershipTermId=6 logPosition=1024 logLeadershipTermId=2" +
            " appendPosition=1218 catchupPosition=800 reason=this is a test",
            builder.toString());
    }