void () { ConcurrentMostlySingularMultiMap<String, String> map = new ConcurrentMostlySingularMultiMap<>(); List<String> xxxList = Collections.singletonList("xxx"); List<String> empty = Collections.emptyList(); String KEY = "key"; boolean replaced = map.replace(KEY, empty, xxxList); assertThat(replaced).isTrue(); assertThat(map.size()).isEqualTo(1); assertThat(map.get(KEY)).isEqualTo(xxxList); List<String> yyyList = Collections.singletonList("yyy"); replaced = map.replace(KEY, xxxList, yyyList); assertThat(replaced).isTrue(); assertThat(map.size()).isEqualTo(1); assertThat(map.get(KEY)).isEqualTo(yyyList); replaced = map.replace(KEY, yyyList, empty); assertThat(replaced).isTrue(); assertThat(map.isEmpty()).isTrue(); assertThat(map.get(KEY)).isEqualTo(empty); }