use of com.google.common.collect.testing.features.MapFeature.ALLOWS_NULL_VALUES in project guava by google.
the class MapComputeIfPresentTester method testComputeIfPresent_nullTreatedAsAbsent.
@MapFeature.Require({ SUPPORTS_PUT, ALLOWS_NULL_VALUES })
@CollectionSize.Require(absent = ZERO)
public void testComputeIfPresent_nullTreatedAsAbsent() {
initMapWithNullValue();
assertNull("computeIfPresent(presentAssignedToNull, function) should return null", getMap().computeIfPresent(getKeyForNullValue(), (k, v) -> {
throw new AssertionFailedError();
}));
expectReplacement(entry(getKeyForNullValue(), null));
}
use of com.google.common.collect.testing.features.MapFeature.ALLOWS_NULL_VALUES in project guava by google.
the class MapMergeTester method testMappedToNull.
@MapFeature.Require({ SUPPORTS_PUT, ALLOWS_NULL_VALUES })
@CollectionSize.Require(absent = ZERO)
public void testMappedToNull() {
initMapWithNullValue();
assertEquals("Map.merge(keyMappedToNull, value, function) should return value", v3(), getMap().merge(getKeyForNullValue(), v3(), (oldV, newV) -> {
throw new AssertionFailedError("Should not call merge function if key was mapped to null");
}));
expectReplacement(entry(getKeyForNullValue(), v3()));
}
Aggregations