@MapFeature.Require({SUPPORTS_PUT, ALLOWS_NULL_KEYS}) @CollectionSize.Require(absent = ZERO) public void testPut_nullKeySupportedPresent() { Entry<K, V> newEntry = entry(null, v3()); initMapWithNullKey(); assertEquals( "put(present, value) should return the associated value", getValueForNullKey(), put(newEntry)); Entry<K, V>[] expected = createArrayWithNullKey(); expected[getNullLocation()] = newEntry; expectContents(expected); }
@MapFeature.Require({SUPPORTS_PUT, ALLOWS_NULL_VALUES}) @CollectionSize.Require(absent = ZERO) public void testPut_replaceNullValueWithNonNullSupported() { Entry<K, V> newEntry = entry(getKeyForNullValue(), v3()); initMapWithNullValue(); assertNull("put(present, value) should return the associated value (null)", put(newEntry)); Entry<K, V>[] expected = createArrayWithNullValue(); expected[getNullLocation()] = newEntry; expectContents(expected); }
@MapFeature.Require({SUPPORTS_PUT, ALLOWS_NULL_VALUES}) public void testPut_nullValueSupported() { assertNull("put(key, null) should return null", put(nullValueEntry)); expectAdded(nullValueEntry); }
@MapFeature.Require(SUPPORTS_PUT) public void testPut_supportedNotPresent() { assertNull("put(notPresent, value) should return null", put(e3())); expectAdded(e3()); }
@MapFeature.Require(absent = SUPPORTS_PUT) public void testPut_unsupportedNotPresent() { try { put(e3()); fail("put(notPresent, value) should throw"); } catch (UnsupportedOperationException expected) { } expectUnchanged(); expectMissing(e3()); }
@MapFeature.Require({SUPPORTS_PUT, ALLOWS_NULL_VALUES}) @CollectionSize.Require(absent = ZERO) public void testPut_replaceNullValueWithNullSupported() { initMapWithNullValue(); assertNull( "put(present, null) should return the associated value (null)", getMap().put(getKeyForNullValue(), null)); expectContents(createArrayWithNullValue()); }
@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_VALUES) public void testPut_nullValueUnsupported() { try { put(nullValueEntry); fail("put(key, null) should throw"); } catch (NullPointerException expected) { } expectUnchanged(); expectNullValueMissingWhenNullValuesUnsupported( "Should not contain null value after unsupported put(key, null)"); }
@MapFeature.Require(SUPPORTS_PUT) @CollectionSize.Require(absent = ZERO) public void testPut_supportedPresent() { assertEquals("put(present, value) should return the old value", v0(), getMap().put(k0(), v3())); expectReplacement(entry(k0(), v3())); }
@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_KEYS) public void testPut_nullKeyUnsupported() { try { put(nullKeyEntry); fail("put(null, value) should throw"); } catch (NullPointerException expected) { } expectUnchanged(); expectNullKeyMissingWhenNullKeysUnsupported( "Should not contain null key after unsupported put(null, value)"); }
@MapFeature.Require(absent = SUPPORTS_PUT) @CollectionSize.Require(absent = ZERO) public void testPut_unsupportedPresentExistingValue() { try { assertEquals("put(present, existingValue) should return present or throw", v0(), put(e0())); } catch (UnsupportedOperationException tolerated) { } expectUnchanged(); }
@MapFeature.Require({SUPPORTS_PUT, ALLOWS_NULL_VALUES}) @CollectionSize.Require(absent = ZERO) public void testPut_replaceWithNullValueSupported() { assertEquals( "put(present, null) should return the associated value", v0(), put(presentKeyNullValueEntry)); expectReplacement(presentKeyNullValueEntry); }
@MapFeature.Require(absent = SUPPORTS_PUT) @CollectionSize.Require(absent = ZERO) public void testPut_unsupportedPresentExistingValue() { try { assertEquals("put(present, existingValue) should return present or throw", samples.e0.getValue(), put(samples.e0)); } catch (UnsupportedOperationException tolerated) { } expectUnchanged(); }
@MapFeature.Require({SUPPORTS_PUT, ALLOWS_NULL_VALUES}) @CollectionSize.Require(absent = ZERO) public void testPut_replaceWithNullValueSupported() { assertEquals("put(present, null) should return the associated value", samples.e0.getValue(), put(presentKeyNullValueEntry)); expectReplacement(presentKeyNullValueEntry); }
@MapFeature.Require({SUPPORTS_PUT, ALLOWS_NULL_VALUES}) @CollectionSize.Require(absent = ZERO) public void testPut_replaceNullValueWithNullSupported() { initMapWithNullValue(); assertNull( "put(present, null) should return the associated value (null)", getMap().put(getKeyForNullValue(), null)); expectContents(createArrayWithNullValue()); }
@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_VALUES) @CollectionSize.Require(absent = ZERO) public void testPut_replaceWithNullValueUnsupported() { try { put(presentKeyNullValueEntry); fail("put(present, null) should throw"); } catch (NullPointerException expected) { } expectUnchanged(); expectNullValueMissingWhenNullValuesUnsupported( "Should not contain null after unsupported put(present, null)"); }
@MapFeature.Require(absent = SUPPORTS_PUT) public void testPut_unsupportedNotPresent() { try { put(e3()); fail("put(notPresent, value) should throw"); } catch (UnsupportedOperationException expected) { } expectUnchanged(); expectMissing(e3()); }
@MapFeature.Require(SUPPORTS_PUT) @CollectionSize.Require(absent = ZERO) public void testPut_supportedPresent() { assertEquals("put(present, value) should return the old value", v0(), getMap().put(k0(), v3())); expectReplacement(entry(k0(), v3())); }
@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_KEYS) public void testPut_nullKeyUnsupported() { try { put(nullKeyEntry); fail("put(null, value) should throw"); } catch (NullPointerException expected) { } expectUnchanged(); expectNullKeyMissingWhenNullKeysUnsupported( "Should not contain null key after unsupported put(null, value)"); }