LogSequenceNumber implements Comparable<LogSequenceNumber> { public static LogSequenceNumber valueOf(long value) { return new LogSequenceNumber(value); } private  LogSequenceNumber(long value); static LogSequenceNumber valueOf(long value); static LogSequenceNumber valueOf(String strValue); long asLong(); String asString(); @Override boolean equals(@Nullable Object o); @Override int hashCode(); @Override String toString(); @Override int compareTo(LogSequenceNumber o); static final LogSequenceNumber INVALID_LSN; }
@Test public void testNotNullWhenCreateFromStr() throws Exception { LogSequenceNumber result = LogSequenceNumber.valueOf("0/15D68C50"); assertThat(result, notNullValue()); }
@Test public void testParseNotValidLSNStr() throws Exception { LogSequenceNumber result = LogSequenceNumber.valueOf("15D68C55"); assertThat(result, equalTo(LogSequenceNumber.INVALID_LSN)); }
@Test public void testEqualLSN() throws Exception { LogSequenceNumber first = LogSequenceNumber.valueOf("0/15D690F8"); LogSequenceNumber second = LogSequenceNumber.valueOf("0/15D690F8"); assertThat(first, equalTo(second)); }
@Test public void testEqualLSNCreateByDifferentWay() throws Exception { LogSequenceNumber first = LogSequenceNumber.valueOf("0/15D690F8"); LogSequenceNumber second = LogSequenceNumber.valueOf(366383352L); assertThat("LSN creates as 64-bit number and as string where each 8-bit print in hex form " + "via slash represent same position in WAL should be equals", first, equalTo(second) ); }
@Test public void testNotEqualLSN() throws Exception { LogSequenceNumber first = LogSequenceNumber.valueOf("0/15D690F8"); LogSequenceNumber second = LogSequenceNumber.valueOf("0/15D68C50"); assertThat(first, not(equalTo(second))); }