List of usage examples for com.google.common.collect.testing.features MapFeature ALLOWS_NULL_VALUES
MapFeature ALLOWS_NULL_VALUES
To view the source code for com.google.common.collect.testing.features MapFeature ALLOWS_NULL_VALUES.
Click Source Link
From source file:org.java0.collection.ArrayMapSuite.java
public static TestSuite suite() { TestStringMapGenerator generator = new TestStringMapGenerator() { @Override/*from ww w .ja v a 2 s . c o m*/ protected Map<String, String> create(Entry<String, String>[] entries) { Map<String, String> map = new ArrayMap<>(); for (Entry<String, String> entry : entries) { map.put(entry.getKey(), entry.getValue()); } return map; } }; TestSuite suite = MapTestSuiteBuilder.using(generator).named("ArrayMapSuite") .withFeatures(MapFeature.GENERAL_PURPOSE, MapFeature.ALLOWS_NULL_VALUES, CollectionFeature.SUPPORTS_ITERATOR_REMOVE, CollectionSize.ANY) .createTestSuite(); return suite; }
From source file:org.java0.collection.HashSetMapSuite.java
public static TestSuite suite() { TestMapGenerator<String, Set<String>> generator = new TestMapGenerator<String, Set<String>>() { @Override/* w w w. ja v a2 s . c om*/ public SampleElements<Map.Entry<String, Set<String>>> samples() { return new SampleElements<Map.Entry<String, Set<String>>>( Helpers.mapEntry("AAA", (Set<String>) new HashSet<String>(Arrays.asList(new String[] { "111", "222" }))), Helpers.mapEntry("BBB", (Set<String>) new HashSet<String>(Arrays.asList(new String[] { "333", "444" }))), Helpers.mapEntry("CCC", (Set<String>) new HashSet<String>(Arrays.asList(new String[] { "555", "666" }))), Helpers.mapEntry("DDD", (Set<String>) new HashSet<String>(Arrays.asList(new String[] { "777", "888" }))), Helpers.mapEntry("EEE", (Set<String>) new HashSet<String>(Arrays.asList(new String[] { "999", "000" })))); } @Override public Map<String, Set<String>> create(Object... entries) { Map<String, Set<String>> map = new HashSetMap<String, String>(); for (Object o : entries) { @SuppressWarnings("unchecked") Entry<String, Set<String>> entry = (Entry<String, Set<String>>) o; map.put(entry.getKey(), entry.getValue()); } return map; } @Override @SuppressWarnings("unchecked") public final Entry<String, Set<String>>[] createArray(int length) { return new Entry[length]; } @Override public final String[] createKeyArray(int length) { return new String[length]; } @SuppressWarnings("unchecked") @Override public final HashSet<String>[] createValueArray(int length) { return new HashSet[length]; } /** Returns the original element list, unchanged. */ @Override public Iterable<Entry<String, Set<String>>> order(List<Entry<String, Set<String>>> insertionOrder) { return insertionOrder; } }; TestSuite suite = MapTestSuiteBuilder.using(generator).named("HashSetMapSuite") .withFeatures(MapFeature.GENERAL_PURPOSE, MapFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION, MapFeature.SUPPORTS_PUT, MapFeature.SUPPORTS_REMOVE, MapFeature.ALLOWS_NULL_KEYS, MapFeature.ALLOWS_NULL_VALUES, CollectionFeature.SUPPORTS_ITERATOR_REMOVE, CollectionSize.ANY) .createTestSuite(); return suite; }