@Test public void testGetNextMessage() { NullMessageIdTracker tracker = new NullMessageIdTracker(INITIAL_MID, 0, TOTAL_NO_OF_MIDS); for (int count = 0; count < TOTAL_NO_OF_MIDS * 16; ++count) { int mid = tracker.getNextMessageId(); assertThat(mid, is(count % TOTAL_NO_OF_MIDS)); } }
public int getNextMessageId() { int mid = currentMID.getAndIncrement(); int result = mid % range; if (result == (range - 1)) { currentMID.addAndGet(-range); } return min + mid; }
NullMessageIdTracker implements MessageIdTracker { public int getNextMessageId() { int mid = currentMID.getAndIncrement(); int result = mid % range; if (result == (range - 1)) { currentMID.addAndGet(-range); } return min + mid; } }
NullMessageIdTracker implements MessageIdTracker { public int getNextMessageId() { int mid = currentMID.getAndIncrement(); int result = mid % range; if (result == (range - 1)) { currentMID.addAndGet(-range); } return min + mid; } NullMessageIdTracker(int initialMid, int minMid, int maxMid); }
NullMessageIdTracker implements MessageIdTracker { public int getNextMessageId() { int mid = currentMID.getAndIncrement(); int result = mid % range; if (result == (range - 1)) { currentMID.addAndGet(-range); } return min + mid; } NullMessageIdTracker(int initialMid, int minMid, int maxMid); int getNextMessageId(); }
NullMessageIdTracker implements MessageIdTracker { public int getNextMessageId() { int mid = currentMID.getAndIncrement(); int result = mid % range; if (result == (range - 1)) { currentMID.addAndGet(-range); } return min + mid; } NullMessageIdTracker(int initialMid, int minMid, int maxMid); int getNextMessageId();  }