public static class FilteredMapTests extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(MapTestSuiteBuilder.using(
new TestStringMapGenerator() {
@Override protected Map<String, String> create(
Entry<String, String>[] entries) {
Map<String, String> map = Maps.newHashMap();
for (Entry<String, String> entry : entries) {
map.put(entry.getKey(), entry.getValue());
}
map.putAll(ENTRIES_TO_FILTER_OUT);
return Maps.filterKeys(map, new Predicate<String>() {
public boolean apply(String input) {
return input == null
|| (input.charAt(0) >= 'a' && input.charAt(0) <= 'z');
}
});
}
})
.named("Maps.filterKeys")
.withFeatures(
CollectionSize.ANY,
MapFeature.ALLOWS_NULL_KEYS,
MapFeature.ALLOWS_NULL_VALUES,
MapFeature.GENERAL_PURPOSE)
.suppressing(getIteratorUnknownOrderRemoveSupportedMethod())
.createTestSuite());
suite.addTest(MapTestSuiteBuilder.using(
new TestStringMapGenerator() {
@Override protected Map<String, String> create(
Entry<String, String>[] entries) {
Map<String, String> map = Maps.newHashMap();
for (Entry<String, String> entry : entries) {
map.put(entry.getKey(), entry.getValue());
}
map.putAll(ENTRIES_TO_FILTER_OUT);
return Maps.filterValues(map, new Predicate<String>() {
public boolean apply(String input) {
return input == null
|| (input.charAt(0) >= 'A' && input.charAt(0) <= 'Z');
}
});
}
})
.named("Maps.filterValues")
.withFeatures(
CollectionSize.ANY,
MapFeature.ALLOWS_NULL_KEYS,
MapFeature.ALLOWS_NULL_VALUES,
MapFeature.GENERAL_PURPOSE)
.suppressing(getIteratorUnknownOrderRemoveSupportedMethod())
.createTestSuite());
suite.addTest(MapTestSuiteBuilder.using(
new TestStringMapGenerator() {
@Override protected Map<String, String> create(
Entry<String, String>[] entries) {
Map<String, String> map = Maps.newHashMap();
for (Entry<String, String> entry : entries) {
map.put(entry.getKey(), entry.getValue());
}
map.putAll(ENTRIES_TO_FILTER_OUT);
return Maps.filterEntries(map,
new Predicate<Entry<String, String>>() {
public boolean apply(Entry<String, String> entry) {
String input = entry.getKey();
return input == null
|| (input.charAt(0) >= 'a' && input.charAt(0) <= 'z');
}
});
}
})
.named("Maps.filterEntries")
.withFeatures(
CollectionSize.ANY,
MapFeature.ALLOWS_NULL_KEYS,
MapFeature.ALLOWS_NULL_VALUES,
MapFeature.GENERAL_PURPOSE)
.suppressing(getIteratorUnknownOrderRemoveSupportedMethod())
.createTestSuite());
suite.addTest(MapTestSuiteBuilder.using(
new TestStringMapGenerator() {
@Override protected Map<String, String> create(
Entry<String, String>[] entries) {
Map<String, String> map = Maps.newHashMap();
for (Entry<String, String> entry : entries) {
map.put(entry.getKey(), entry.getValue());