Search in sources :

Example 6 with SUPPORTS_PUT

use of com.google.common.collect.testing.features.MapFeature.SUPPORTS_PUT in project guava by google.

the class MapComputeIfAbsentTester method testComputeIfAbsent_supportedPresent.

@MapFeature.Require(SUPPORTS_PUT)
@CollectionSize.Require(absent = ZERO)
public void testComputeIfAbsent_supportedPresent() {
    assertEquals("computeIfAbsent(present, function) should return existing value", v0(), getMap().computeIfAbsent(k0(), k -> {
        throw new AssertionFailedError();
    }));
    expectUnchanged();
}
Also used : GwtCompatible(com.google.common.annotations.GwtCompatible) AbstractMapTester(com.google.common.collect.testing.AbstractMapTester) ZERO(com.google.common.collect.testing.features.CollectionSize.ZERO) Map(java.util.Map) SUPPORTS_PUT(com.google.common.collect.testing.features.MapFeature.SUPPORTS_PUT) ALLOWS_NULL_VALUES(com.google.common.collect.testing.features.MapFeature.ALLOWS_NULL_VALUES) AssertionFailedError(junit.framework.AssertionFailedError) ALLOWS_NULL_KEYS(com.google.common.collect.testing.features.MapFeature.ALLOWS_NULL_KEYS) MapFeature(com.google.common.collect.testing.features.MapFeature) CollectionSize(com.google.common.collect.testing.features.CollectionSize) AssertionFailedError(junit.framework.AssertionFailedError)

Example 7 with SUPPORTS_PUT

use of com.google.common.collect.testing.features.MapFeature.SUPPORTS_PUT in project guava by google.

the class MapMergeTester method testMergeAbsentNullKey.

@MapFeature.Require({ SUPPORTS_PUT, ALLOWS_NULL_KEYS })
public void testMergeAbsentNullKey() {
    assertEquals("Map.merge(null, value, function) should return value", v3(), getMap().merge(null, v3(), (oldV, newV) -> {
        throw new AssertionFailedError("Should not call merge function if key was absent");
    }));
    expectAdded(entry(null, v3()));
}
Also used : AbstractMapTester(com.google.common.collect.testing.AbstractMapTester) ZERO(com.google.common.collect.testing.features.CollectionSize.ZERO) ALLOWS_NULL_VALUES(com.google.common.collect.testing.features.MapFeature.ALLOWS_NULL_VALUES) GwtIncompatible(com.google.common.annotations.GwtIncompatible) AssertionFailedError(junit.framework.AssertionFailedError) ALLOWS_NULL_KEYS(com.google.common.collect.testing.features.MapFeature.ALLOWS_NULL_KEYS) CollectionSize(com.google.common.collect.testing.features.CollectionSize) GwtCompatible(com.google.common.annotations.GwtCompatible) Helpers(com.google.common.collect.testing.Helpers) Map(java.util.Map) SUPPORTS_PUT(com.google.common.collect.testing.features.MapFeature.SUPPORTS_PUT) SUPPORTS_REMOVE(com.google.common.collect.testing.features.MapFeature.SUPPORTS_REMOVE) MapFeature(com.google.common.collect.testing.features.MapFeature) Method(java.lang.reflect.Method) AssertionFailedError(junit.framework.AssertionFailedError)

Aggregations

GwtCompatible (com.google.common.annotations.GwtCompatible)7 AbstractMapTester (com.google.common.collect.testing.AbstractMapTester)7 CollectionSize (com.google.common.collect.testing.features.CollectionSize)7 ZERO (com.google.common.collect.testing.features.CollectionSize.ZERO)7 MapFeature (com.google.common.collect.testing.features.MapFeature)7 ALLOWS_NULL_KEYS (com.google.common.collect.testing.features.MapFeature.ALLOWS_NULL_KEYS)7 ALLOWS_NULL_VALUES (com.google.common.collect.testing.features.MapFeature.ALLOWS_NULL_VALUES)7 SUPPORTS_PUT (com.google.common.collect.testing.features.MapFeature.SUPPORTS_PUT)7 Map (java.util.Map)7 AssertionFailedError (junit.framework.AssertionFailedError)7 GwtIncompatible (com.google.common.annotations.GwtIncompatible)3 Helpers (com.google.common.collect.testing.Helpers)3 SUPPORTS_REMOVE (com.google.common.collect.testing.features.MapFeature.SUPPORTS_REMOVE)3 Method (java.lang.reflect.Method)3 Entry (java.util.Map.Entry)3