@Test public void addAllShouldRemoveDuplicates() { testee.addAll(ImmutableList.of( messageUid1, messageUid2, messageUid2, messageUid3, messageUid4)); assertThat(mapTesteeInternalDataToMsnByUid().entrySet()) .containsExactlyElementsOf(ImmutableMap.of( 1, messageUid1, 2, messageUid2, 3, messageUid3, 4, messageUid4).entrySet()); }
public synchronized void addAll(List<MessageUid> addedUids) { TreeSet<MessageUid> tmp = new TreeSet<>(); tmp.addAll(uids); tmp.addAll(addedUids); uids.clear(); uids.addAll(tmp); }
UidMsnConverter { public synchronized void addAll(List<MessageUid> addedUids) { TreeSet<MessageUid> tmp = new TreeSet<>(); tmp.addAll(uids); tmp.addAll(addedUids); uids.clear(); uids.addAll(tmp); } }
UidMsnConverter { public synchronized void addAll(List<MessageUid> addedUids) { TreeSet<MessageUid> tmp = new TreeSet<>(); tmp.addAll(uids); tmp.addAll(addedUids); uids.clear(); uids.addAll(tmp); } UidMsnConverter(); }
UidMsnConverter { public synchronized void addAll(List<MessageUid> addedUids) { TreeSet<MessageUid> tmp = new TreeSet<>(); tmp.addAll(uids); tmp.addAll(addedUids); uids.clear(); uids.addAll(tmp); } 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 addAll(List<MessageUid> addedUids) { TreeSet<MessageUid> tmp = new TreeSet<>(); tmp.addAll(uids); tmp.addAll(addedUids); uids.clear(); uids.addAll(tmp); } 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; }