@MapFeature.Require(SUPPORTS_PUT) @CollectionSize.Require(absent = ZERO) public void testSetValue() { for (Entry<K, V> entry : getMap().entrySet()) { if (entry.getKey().equals(k0())) { assertEquals("entry.setValue() should return the old value", v0(), entry.setValue(v3())); break; } } expectReplacement(entry(k0(), v3())); }
@CollectionSize.Require(ONE) @CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE) public void testEntrySetIteratorRemove() { Set<Entry<K, V>> entrySet = getMap().entrySet(); Iterator<Entry<K, V>> entryItr = entrySet.iterator(); assertEquals(e0(), entryItr.next()); entryItr.remove(); assertTrue(getMap().isEmpty()); assertFalse(entrySet.contains(e0())); }
@Override protected Collection<Method> suppressForConcurrentSkipListMap() { List<Method> methods = newArrayList(); methods.addAll(super.suppressForConcurrentSkipListMap()); methods.add(getContainsEntryWithIncomparableKeyMethod()); methods.add(getContainsEntryWithIncomparableValueMethod()); return methods; }
protected Collection<Method> suppressForConcurrentSkipListMap() { return asList( MapEntrySetTester.getSetValueMethod(), MapEntrySetTester.getSetValueWithNullValuesAbsentMethod(), MapEntrySetTester.getSetValueWithNullValuesPresentMethod()); }
@CollectionSize.Require(absent = ZERO) @MapFeature.Require(ALLOWS_NULL_VALUES) public void testContainsEntryWithNullValuePresent() { initMapWithNullValue(); assertTrue(getMap().entrySet().contains(Helpers.mapEntry(getKeyForNullValue(), null))); }
@CollectionSize.Require(absent = ZERO) @MapFeature.Require(ALLOWS_NULL_KEYS) public void testContainsEntryWithNullKeyPresent() { initMapWithNullKey(); assertTrue(getMap().entrySet().contains(Helpers.mapEntry(null, getValueForNullKey()))); }
public void testContainsEntryWithIncomparableKey() { try { assertFalse(getMap().entrySet().contains(Helpers.mapEntry(IncomparableType.INSTANCE, v0()))); } catch (ClassCastException acceptable) { // allowed by the spec } }
public void testContainsEntryWithIncomparableValue() { try { assertFalse(getMap().entrySet().contains(Helpers.mapEntry(k0(), IncomparableType.INSTANCE))); } catch (ClassCastException acceptable) { // allowed by the spec } }
public void testContainsEntryWithIncomparableKey() { assertFalse(getMap() .entrySet().contains(Helpers.mapEntry(IncomparableType.INSTANCE, samples.e0.getValue()))); }
@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_VALUES) @CollectionSize.Require(absent = ZERO) public void testSetValueWithNullValuesAbsent() { for (Entry<K, V> entry : getMap().entrySet()) { try { entry.setValue(null); fail("Expected NullPointerException"); } catch (NullPointerException exception) { break; } } expectUnchanged(); }
.suppressing(MapEntrySetTester.getSetValueMethod()) .createTestSuite());
@CollectionSize.Require(absent = ZERO) @MapFeature.Require(ALLOWS_NULL_VALUES) public void testContainsEntryWithNullValuePresent() { initMapWithNullValue(); assertTrue(getMap().entrySet().contains(Helpers.mapEntry(getKeyForNullValue(), null))); }
@CollectionSize.Require(absent = ZERO) @MapFeature.Require(ALLOWS_NULL_KEYS) public void testContainsEntryWithNullKeyPresent() { initMapWithNullKey(); assertTrue(getMap().entrySet().contains(Helpers.mapEntry(null, getValueForNullKey()))); }
MapEntrySetTester.getSetValueMethod(), MapEntrySetTester.getSetValueWithNullValuesAbsentMethod(), MapEntrySetTester.getSetValueWithNullValuesPresentMethod()) .createTestSuite());
@MapFeature.Require(ALLOWS_NULL_KEY_QUERIES) public void testContainsEntryWithNullKeyAbsent() { assertFalse(getMap().entrySet().contains(Helpers.mapEntry(null, v0()))); }
@MapFeature.Require(ALLOWS_NULL_VALUE_QUERIES) public void testContainsEntryWithNullValueAbsent() { assertFalse(getMap().entrySet().contains(Helpers.mapEntry(k0(), null))); }
public void testContainsEntryWithIncomparableValue() { assertFalse(getMap() .entrySet().contains(Helpers.mapEntry(samples.e0.getKey(), IncomparableType.INSTANCE))); }
@MapFeature.Require(value = SUPPORTS_PUT, absent = ALLOWS_NULL_VALUES) @CollectionSize.Require(absent = ZERO) public void testSetValueWithNullValuesAbsent() { for (Entry<K, V> entry : getMap().entrySet()) { try { entry.setValue(null); fail("Expected NullPointerException"); } catch (NullPointerException exception) { break; } } expectUnchanged(); }
@MapFeature.Require({SUPPORTS_PUT, ALLOWS_NULL_VALUES}) @CollectionSize.Require(absent = ZERO) public void testSetValueWithNullValuesPresent() { for (Entry<K, V> entry : getMap().entrySet()) { if (entry.getKey().equals(k0())) { assertEquals("entry.setValue() should return the old value", v0(), entry.setValue(null)); break; } } expectReplacement(entry(k0(), (V) null)); }
@CollectionSize.Require(ONE) @CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE) public void testEntrySetIteratorRemove() { Set<Entry<K, V>> entrySet = getMap().entrySet(); Iterator<Entry<K, V>> entryItr = entrySet.iterator(); assertEquals(e0(), entryItr.next()); entryItr.remove(); assertTrue(getMap().isEmpty()); assertFalse(entrySet.contains(e0())); }