@MapFeature.Require(absent = SUPPORTS_PUT) public void testPutAll_unsupportedNonePresent() { try { putAll(createDisjointCollection()); fail("putAll(nonePresent) should throw"); } catch (UnsupportedOperationException expected) { } expectUnchanged(); expectMissing(e3(), e4()); }
@MapFeature.Require(absent = SUPPORTS_PUT) public void testPutAll_unsupportedNothing() { try { getMap().putAll(emptyMap()); } catch (UnsupportedOperationException tolerated) { } expectUnchanged(); }
@MapFeature.Require(SUPPORTS_PUT) public void testPutAll_supportedNonePresent() { putAll(createDisjointCollection()); expectAdded(e3(), e4()); }
@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_KEYS) public void testPutAll_nullKeyUnsupported() { try { putAll(containsNullKey); fail("putAll(containsNullKey) should throw"); } catch (NullPointerException expected) { } expectUnchanged(); expectNullKeyMissingWhenNullKeysUnsupported( "Should not contain null key after unsupported putAll(containsNullKey)"); }
@MapFeature.Require(absent = SUPPORTS_PUT) public void testPutAll_unsupportedNonePresent() { try { putAll(createDisjointCollection()); fail("putAll(nonePresent) should throw"); } catch (UnsupportedOperationException expected) { } expectUnchanged(); expectMissing(samples.e3, samples.e4); }
@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_VALUES) public void testPutAll_nullValueUnsupported() { try { putAll(containsNullValue); fail("putAll(containsNullValue) should throw"); } catch (NullPointerException expected) { } expectUnchanged(); expectNullValueMissingWhenNullValuesUnsupported( "Should not contain null value after unsupported putAll(containsNullValue)"); }
@MapFeature.Require({FAILS_FAST_ON_CONCURRENT_MODIFICATION, SUPPORTS_PUT}) @CollectionSize.Require(absent = ZERO) public void testPutAllSomePresentConcurrentWithEntrySetIteration() { try { Iterator<Entry<K, V>> iterator = getMap().entrySet().iterator(); putAll(MinimalCollection.of(e3(), e0())); iterator.next(); fail("Expected ConcurrentModificationException"); } catch (ConcurrentModificationException expected) { // success } }
@MapFeature.Require(absent = SUPPORTS_PUT) @CollectionSize.Require(absent = ZERO) public void testPutAll_unsupportedSomePresent() { try { putAll(MinimalCollection.of(e3(), e0())); fail("putAll(somePresent) should throw"); } catch (UnsupportedOperationException expected) { } expectUnchanged(); }
@MapFeature.Require({SUPPORTS_PUT, ALLOWS_NULL_KEYS}) public void testPutAll_nullKeySupported() { putAll(containsNullKey); expectAdded(containsNullKey.get(0)); }
@MapFeature.Require(SUPPORTS_PUT) @CollectionSize.Require(absent = ZERO) public void testPutAll_supportedSomePresent() { putAll(MinimalCollection.of(e3(), e0())); expectAdded(e3()); }
@MapFeature.Require(SUPPORTS_PUT) public void testPutAll_supportedNonePresent() { putAll(createDisjointCollection()); expectAdded(samples.e3, samples.e4); }
@MapFeature.Require({ FAILS_FAST_ON_CONCURRENT_MODIFICATION, SUPPORTS_PUT }) @CollectionSize.Require(absent = ZERO) public void testPutAllSomePresentConcurrentWithEntrySetIteration() { try { Iterator<Entry<K, V>> iterator = getMap().entrySet().iterator(); putAll(MinimalCollection.of(samples.e3, samples.e0)); iterator.next(); fail("Expected ConcurrentModificationException"); } catch (ConcurrentModificationException expected) { // success } }
@MapFeature.Require(absent = SUPPORTS_PUT) @CollectionSize.Require(absent = ZERO) public void testPutAll_unsupportedSomePresent() { try { putAll(MinimalCollection.of(samples.e3, samples.e0)); fail("putAll(somePresent) should throw"); } catch (UnsupportedOperationException expected) { } expectUnchanged(); }
@MapFeature.Require(absent = SUPPORTS_PUT) @CollectionSize.Require(absent = ZERO) public void testPutAll_unsupportedAllPresent() { try { putAll(MinimalCollection.of(e0())); } catch (UnsupportedOperationException tolerated) { } expectUnchanged(); }
@MapFeature.Require(absent = SUPPORTS_PUT) @CollectionSize.Require(absent = ZERO) public void testPutAll_unsupportedAllPresent() { try { putAll(MinimalCollection.of(samples.e0)); } catch (UnsupportedOperationException tolerated) { } expectUnchanged(); }
private void putAll(Iterable<Entry<K, V>> entries) { Map<K, V> map = new LinkedHashMap<>(); for (Entry<K, V> entry : entries) { map.put(entry.getKey(), entry.getValue()); } getMap().putAll(map); }
@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_KEYS) public void testPutAll_nullKeyUnsupported() { try { putAll(containsNullKey); fail("putAll(containsNullKey) should throw"); } catch (NullPointerException expected) { } expectUnchanged(); expectNullKeyMissingWhenNullKeysUnsupported( "Should not contain null key after unsupported putAll(containsNullKey)"); }