Source:
<code>public void testInitSequence() { <START> UIDSequencer seq = uidGeneratorService.getSequencer(); <END> assertTrue(seq.getClass().isAssignableFrom(MongoDBUIDSequencer.class)); seq.getNext("autoSequence"); seq.getNext("autoSequence"); assertTrue(seq.getNext("autoSequence") > 2); seq.initSequence("mySequence", 1); assertTrue(seq.getNext("mySequence") > 1); assertTrue(seq.getNext("mySequence") < 10); seq.initSequence("mySequence", 10); assertTrue("Sequence should skip ahead to 10", seq.getNext("mySequence") > 10); assertTrue(seq.getNextLong("mySequence") > 10); List<LoggingEvent> caughtEvents = logCaptureResult.getCaughtEvents(); assertEquals(0, caughtEvents.size()); logFeature.hideWarningFromConsoleLog(); try { seq.initSequence("mySequence", 5); caughtEvents = logCaptureResult.getCaughtEvents(); assertEquals(1, caughtEvents.size()); assertEquals("Failed to update the sequence 'mySequence' with value 5", caughtEvents.get(0).getRenderedMessage()); logCaptureResult.clear(); seq.initSequence("another", 500); caughtEvents = logCaptureResult.getCaughtEvents(); assertEquals(0, caughtEvents.size()); seq.initSequence("another", 500); caughtEvents = logCaptureResult.getCaughtEvents(); assertEquals(1, caughtEvents.size()); assertEquals("Failed to update the sequence 'another' with value 500", caughtEvents.get(0).getRenderedMessage()); assertTrue("Sequence should be at 500",seq.getNext("another") == 501); logCaptureResult.clear(); seq.initSequence("another", 499); caughtEvents = logCaptureResult.getCaughtEvents(); assertEquals(1, caughtEvents.size()); assertEquals("Failed to update the sequence 'another' with value 499", caughtEvents.get(0).getRenderedMessage()); logCaptureResult.clear(); seq.initSequence("another", 9999); caughtEvents = logCaptureResult.getCaughtEvents(); assertEquals(0, caughtEvents.size()); assertTrue("Sequence should be at 10000",seq.getNext("another") == 10000); } finally { logFeature.restoreConsoleLog(); } }</code><technical_language>prevent assertEquals(11, seq.getNext("mySequence"))</technical_language>

Target:
public void testInitSequence() { UIDSequencer seq = uidGeneratorService.getSequencer(); seq.getNext("autoSequence"); seq.getNext("autoSequence"); assertTrue(seq.getNext("autoSequence") > 2); seq.initSequence("mySequence", 1); assertTrue(seq.getNext("mySequence") > 1); assertTrue(seq.getNext("mySequence") < 10); seq.initSequence("mySequence", 10); assertTrue("Sequence should skip ahead to 10", seq.getNext("mySequence") > 10); assertTrue(seq.getNextLong("mySequence") > 10); try { seq.initSequence("mySequence", 5); fail(); } catch (NuxeoException ne) { assertEquals("Failed to update the sequence 'mySequence' with value 5", ne.getMessage()); } seq.initSequence("another", 500); try { seq.initSequence("another", 500); fail(); } catch (NuxeoException ne) { assertEquals("Failed to update the sequence 'another' with value 500", ne.getMessage()); } assertTrue("Sequence should be greater than 500",seq.getNext("another") > 500); try { seq.initSequence("another", 499); fail(); } catch (NuxeoException ne) { assertEquals("Failed to update the sequence 'another' with value 499", ne.getMessage()); } seq.initSequence("another", 9999); assertTrue("Sequence should be at 10000",seq.getNext("another") >= 10000); }