@Test public void addUidShouldBeIdempotent() { testee.addUid(messageUid1); testee.addUid(messageUid1); assertThat(mapTesteeInternalDataToMsnByUid()) .isEqualTo(ImmutableMap.of(1, messageUid1)); }
public synchronized void addUid(MessageUid uid) { if (uids.contains(uid)) { return; } if (isLastUid(uid)) { uids.add(uid); } else { uids.add(uid); Collections.sort(uids); } }
UidMsnConverter { public synchronized void addUid(MessageUid uid) { if (uids.contains(uid)) { return; } if (isLastUid(uid)) { uids.add(uid); } else { uids.add(uid); Collections.sort(uids); } } }
UidMsnConverter { public synchronized void addUid(MessageUid uid) { if (uids.contains(uid)) { return; } if (isLastUid(uid)) { uids.add(uid); } else { uids.add(uid); Collections.sort(uids); } } UidMsnConverter(); }
UidMsnConverter { public synchronized void addUid(MessageUid uid) { if (uids.contains(uid)) { return; } if (isLastUid(uid)) { uids.add(uid); } else { uids.add(uid); Collections.sort(uids); } } UidMsnConverter(); synchronized void addAll(List<MessageUid> addedUids); synchronized NullableMessageSequenceNumber getMsn(MessageUid uid); synchronized Optional<MessageUid> getUid(int msn); synchronized Optional<MessageUid> getLastUid(); synchronized Optional<MessageUid> getFirstUid(); synchronized int getNumMessage(); synchronized void remove(MessageUid uid); synchronized boolean isEmpty(); synchronized void clear(); synchronized void addUid(MessageUid uid); }
UidMsnConverter { public synchronized void addUid(MessageUid uid) { if (uids.contains(uid)) { return; } if (isLastUid(uid)) { uids.add(uid); } else { uids.add(uid); Collections.sort(uids); } } UidMsnConverter(); synchronized void addAll(List<MessageUid> addedUids); synchronized NullableMessageSequenceNumber getMsn(MessageUid uid); synchronized Optional<MessageUid> getUid(int msn); synchronized Optional<MessageUid> getLastUid(); synchronized Optional<MessageUid> getFirstUid(); synchronized int getNumMessage(); synchronized void remove(MessageUid uid); synchronized boolean isEmpty(); synchronized void clear(); synchronized void addUid(MessageUid uid); static final int FIRST_MSN; }