@Override
    public int compareTo(final LogId o) {
        // Compare term at first
        final int c = Long.compare(getTerm(), o.getTerm());
        if (c == 0) {
            return Long.compare(getIndex(), o.getIndex());
        } else {
            return c;
        }
    }
@Test
    public void testCompareTo() {
        LogId logId = new LogId();
        assertEquals(0, logId.getIndex());
        assertEquals(0, logId.getTerm());

        assertTrue(new LogId(1, 0).compareTo(logId) > 0);
        assertTrue(new LogId(0, 1).compareTo(logId) > 0);

        logId = new LogId(1, 2);
        assertTrue(new LogId(0, 1).compareTo(logId) < 0);
        assertTrue(new LogId(0, 2).compareTo(logId) < 0);
        assertTrue(new LogId(3, 1).compareTo(logId) < 0);
        assertTrue(new LogId(1, 2).compareTo(logId) == 0);
    }