public Object[] getFullElements() { return getSampleValues(); }
public Object[] getFullElements() { Object[] k = getSampleKeys(); Object[] v = getSampleValues(); return makeEntryArray(k, v); }
/** * Resets the {@link #map}, {@link #entrySet}, {@link #keySet}, * {@link #values} and {@link #confirmed} fields to full. */ public void resetFull() { this.map = makeFullMap(); views(); this.confirmed = makeConfirmedMap(); Object[] k = getSampleKeys(); Object[] v = getSampleValues(); for (int i = 0; i < k.length; i++) { confirmed.put(k[i], v[i]); } }
public void testValuesRemoveChangesMap() { resetFull(); Object[] sampleValues = getSampleValues(); Collection values = map.values(); for (int i = 0; i < sampleValues.length; i++) {
/** * Tests Map.put(null, value) */ @Test public void testMapPutNullKey() { resetFull(); Object[] values = getSampleValues(); if (isPutAddSupported()) { if (isAllowNullKey()) { map.put(null, values[0]); } else { try { map.put(null, values[0]); fail("put(null, value) should throw NPE/IAE"); } catch (NullPointerException ex) { } catch (IllegalArgumentException ex) { } } } }
/** * Tests Map.get(Object) */ @Test public void testMapGet() { resetEmpty(); Object[] keys = getSampleKeys(); Object[] values = getSampleValues(); for (Object key : keys) { assertTrue("Empty map.get() should return null.", map.get(key) == null); } verifyAll(); resetFull(); for (int i = 0; i < keys.length; i++) { assertEquals("Full map.get() should return value from mapping.", values[i], map.get(keys[i])); } }
/** * Tests Map.containsValue(Object) by verifying it returns false for all * sample values on an empty map and returns true for all sample values on * a full map. */ @Test public void testMapContainsValue() { Object[] values = getSampleValues(); resetEmpty(); for (Object value : values) { assertTrue("Empty map must not contain value", !map.containsValue(value)); } verifyAll(); resetFull(); for (Object value : values) { assertTrue("Map must contain value for a mapping in the map.", map.containsValue(value)); } verifyAll(); }
Object[] values = getSampleValues(); for (int i = 0; i < keys.length; i++) { Object o = map.remove(keys[i]);
Object[] values = getSampleValues(); for (int i = 0; i < keys.length; i++) { m2.put(keys[i], values[i]);
/** * Helper method to add all the mappings described by * {@link #getSampleKeys()} and {@link #getSampleValues()}. */ public void addSampleMappings(Map m) { Object[] keys = getSampleKeys(); Object[] values = getSampleValues(); for (int i = 0; i < keys.length; i++) { try { m.put(keys[i], values[i]); } catch (NullPointerException exception) { assertTrue("NullPointerException only allowed to be thrown if either the key or value is null.", keys[i] == null || values[i] == null); assertTrue("NullPointerException on null key, but isAllowNullKey is not overridden to return false.", keys[i] == null || !isAllowNullKey()); assertTrue("NullPointerException on null value, but isAllowNullValue is not overridden to return false.", values[i] == null || !isAllowNullValue()); assertTrue("Unknown reason for NullPointer.", false); } } assertEquals("size must reflect number of mappings added.", keys.length, m.size()); }
resetEmpty(); Object[] keys = getSampleKeys(); Object[] values = getSampleValues(); Object[] newValues = getNewSampleValues();
public Object[] getFullElements() { return getSampleValues(); }
public void testSampleMappings() { Object[] keys = getSampleKeys(); Object[] values = getSampleValues(); Object[] newValues = getNewSampleValues();
public Object[] getFullElements() { Object[] k = getSampleKeys(); Object[] v = getSampleValues(); return makeEntryArray(k, v); }
/** * Resets the {@link #map}, {@link #entrySet}, {@link #keySet}, * {@link #values} and {@link #confirmed} fields to full. */ public void resetFull() { this.map = makeFullMap(); views(); this.confirmed = makeConfirmedMap(); Object[] k = getSampleKeys(); Object[] v = getSampleValues(); for (int i = 0; i < k.length; i++) { confirmed.put(k[i], v[i]); } }
/** * Tests Map.put(null, value) */ @Test public void testMapPutNullKey() { resetFull(); Object[] values = getSampleValues(); if (isPutAddSupported()) { if (isAllowNullKey()) { map.put(null, values[0]); } else { try { map.put(null, values[0]); fail("put(null, value) should throw NPE/IAE"); } catch (NullPointerException ex) { } catch (IllegalArgumentException ex) { } } } }
/** * Tests Map.get(Object) */ @Test public void testMapGet() { resetEmpty(); Object[] keys = getSampleKeys(); Object[] values = getSampleValues(); for (Object key : keys) { assertTrue("Empty map.get() should return null.", map.get(key) == null); } verifyAll(); resetFull(); for (int i = 0; i < keys.length; i++) { assertEquals("Full map.get() should return value from mapping.", values[i], map.get(keys[i])); } }
/** * Tests Map.containsValue(Object) by verifying it returns false for all * sample values on an empty map and returns true for all sample values on * a full map. */ @Test public void testMapContainsValue() { Object[] values = getSampleValues(); resetEmpty(); for (Object value : values) { assertTrue("Empty map must not contain value", !map.containsValue(value)); } verifyAll(); resetFull(); for (Object value : values) { assertTrue("Map must contain value for a mapping in the map.", map.containsValue(value)); } verifyAll(); }
/** * Helper method to add all the mappings described by * {@link #getSampleKeys()} and {@link #getSampleValues()}. */ public void addSampleMappings(Map m) { Object[] keys = getSampleKeys(); Object[] values = getSampleValues(); for (int i = 0; i < keys.length; i++) { try { m.put(keys[i], values[i]); } catch (NullPointerException exception) { assertTrue("NullPointerException only allowed to be thrown if either the key or value is null.", keys[i] == null || values[i] == null); assertTrue("NullPointerException on null key, but isAllowNullKey is not overridden to return false.", keys[i] == null || !isAllowNullKey()); assertTrue("NullPointerException on null value, but isAllowNullValue is not overridden to return false.", values[i] == null || !isAllowNullValue()); assertTrue("Unknown reason for NullPointer.", false); } } assertEquals("size must reflect number of mappings added.", keys.length, m.size()); }
Object[] values = getSampleValues(); for (int i = 0; i < keys.length; i++) { m2.put(keys[i], values[i]);