@Test
public void testNextWithRetryOnce() {

    final Instant execTime = Instant.ofEpochMilli(1L);
    final Instant execTime2 = Instant.ofEpochMilli(3L);
    new Expectations(Instant.class) {
        {
            Instant.now();
            returns(
                execTime, // at initialize
                execTime, // when invoke next method first time.
                execTime2 // when invoke next method second time.
            );
        }
    };
    Camflake camflake = new Camflake(new TestMachineId(), Instant.EPOCH);
    // force update sequence ID to maximum to test retry.
    Deencapsulation.setField(camflake, "counter", new AtomicInteger(SEQUENCE_MAX));
    long id = camflake.next();
    assertThat(id, is(12582913L));
}