Add MultiValueMap.addIfAbsent method

Closes gh-23111
This commit is contained in:
Phillip Webb
2019-06-11 11:45:29 -07:00
parent 0757eaee9d
commit b21b27c5ac
2 changed files with 27 additions and 1 deletions

View File

@@ -47,6 +47,19 @@ public class LinkedMultiValueMapTests {
assertThat(map.get("key")).isEqualTo(expected);
}
@Test
public void addIfAbsentWhenAbsent() {
map.addIfAbsent("key", "value1");
assertThat(map.get("key")).containsExactly("value1");
}
@Test
public void addIfAbsentWhenPresent() {
map.add("key", "value1");
map.addIfAbsent("key", "value2");
assertThat(map.get("key")).containsExactly("value1");
}
@Test
public void set() {
map.set("key", "value1");