@Test
public void testBasicOperations() {
final ConcurrentWeakIdentityHashMap<Integer, String> map = new ConcurrentWeakIdentityHashMap<>();
final Integer key = 1;
final String firstValue = "foo";
final String otherValue = "bar";
assertThat(map.containsKey(key), is(false));
assertThat(map.get(key), nullValue());
assertThat(map.put(key, firstValue), nullValue());
assertThat(map.containsKey(key), is(true));
assertThat(map.putIfAbsent(key, otherValue), is(firstValue));
assertThat(map.replace(key, otherValue, firstValue), is(false));
assertThat(map.get(key), is(firstValue));
assertThat(map.replace(key, firstValue, otherValue), is(true));
assertThat(map.get(key), is(otherValue));
assertThat(map.remove(key, firstValue), is(false));
assertThat(map.get(key), is(otherValue));
assertThat(map.containsKey(key), is(true));
assertThat(map.remove(key, otherValue), is(true));
assertThat(map.containsKey(key), is(false));
assertThat(map.get(key), nullValue());
assertThat(map.putIfAbsent(key, otherValue), nullValue());
assertThat(map.get(key), is(otherValue));
assertThat(map.remove(key), is(otherValue));
assertThat(map.containsKey(key), is(false));
assertThat(map.get(key), nullValue());
}