Package com.google.common.collect.testing

Examples of com.google.common.collect.testing.TestStringMapGenerator


public class LocalCacheTest extends TestCase {

  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(LocalCacheTest.class);
    suite.addTest(MapTestSuiteBuilder.using(new TestStringMapGenerator() {
          @Override public Map<String, String> create(
              Entry<String, String>[] entries) {
            LocalCache<String, String> map = makeLocalCache(createCacheBuilder());
            for (Entry<String, String> entry : entries) {
              map.put(entry.getKey(), entry.getValue());
View Full Code Here


  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());
View Full Code Here

  public static Test suite() {
    TestSuite suite = new TestSuite();

    suite.addTestSuite(ForwardingMapTest.class);
    suite.addTest(MapTestSuiteBuilder.using(new TestStringMapGenerator() {

      @Override protected Map<String, String> create(
          Entry<String, String>[] entries) {
        Map<String, String> map = Maps.newLinkedHashMap();
        for (Entry<String, String> entry : entries) {
          map.put(entry.getKey(), entry.getValue());
        }
        return new StandardImplForwardingMap<String, String>(map);
      }

    }).named("ForwardingMap[LinkedHashMap] with standard implementations")
        .withFeatures(CollectionSize.ANY, MapFeature.ALLOWS_NULL_VALUES,
            MapFeature.ALLOWS_NULL_KEYS, MapFeature.GENERAL_PURPOSE)
        .createTestSuite());
    suite.addTest(MapTestSuiteBuilder.using(new TestStringMapGenerator() {

      @Override protected Map<String, String> create(
          Entry<String, String>[] entries) {
        ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
        for (Entry<String, String> entry : entries) {
View Full Code Here

  public static Test suite() {
    TestSuite suite = new TestSuite();

    suite.addTestSuite(ForwardingSortedMapTest.class);
    suite.addTest(MapTestSuiteBuilder.using(new TestStringMapGenerator() {
      @Override protected Map<String, String> create(
          Entry<String, String>[] entries) {
        SortedMap<String, String> map = new SafeTreeMap<String, String>();
        for (Entry<String, String> entry : entries) {
          map.put(entry.getKey(), entry.getValue());
        }
        return new StandardImplForwardingSortedMap<String, String>(map);
      }

      @Override public Iterable<Entry<String, String>> order(
          List<Entry<String, String>> insertionOrder) {
        return sort(insertionOrder);
      }
    }).named("ForwardingSortedMap[SafeTreeMap] with no comparator and standard "
        + "implementations").withFeatures(CollectionSize.ANY,
        CollectionFeature.KNOWN_ORDER, MapFeature.ALLOWS_NULL_VALUES,
        MapFeature.GENERAL_PURPOSE).createTestSuite());
    suite.addTest(MapTestSuiteBuilder.using(new TestStringMapGenerator() {
      private final Comparator<String> comparator =
          Ordering.natural().nullsFirst();

      @Override protected Map<String, String> create(
          Entry<String, String>[] entries) {
        SortedMap<String, String> map =
            new SafeTreeMap<String, String>(comparator);
        for (Entry<String, String> entry : entries) {
          map.put(entry.getKey(), entry.getValue());
        }
        return new StandardImplForwardingSortedMap<String, String>(map);
      }

      @Override public Iterable<Entry<String, String>> order(
          List<Entry<String, String>> insertionOrder) {
        return sort(insertionOrder);
      }
    }).named("ForwardingSortedMap[SafeTreeMap] with natural comparator and "
        + "standard implementations").withFeatures(CollectionSize.ANY,
        CollectionFeature.KNOWN_ORDER, MapFeature.ALLOWS_NULL_VALUES,
        MapFeature.ALLOWS_NULL_KEYS, MapFeature.GENERAL_PURPOSE)
        .createTestSuite());
    suite.addTest(MapTestSuiteBuilder.using(new TestStringMapGenerator() {
      @Override protected Map<String, String> create(
          Entry<String, String>[] entries) {
        ImmutableSortedMap.Builder<String, String> builder =
            ImmutableSortedMap.naturalOrder();
        for (Entry<String, String> entry : entries) {
View Full Code Here

*/
public class MapsCollectionTest extends TestCase {
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTest(NavigableMapTestSuiteBuilder
        .using(new TestStringMapGenerator() {
          @Override
          protected Map<String, String> create(Entry<String, String>[] entries) {
            SafeTreeMap<String, String> map = new SafeTreeMap<String, String>();
            for (Entry<String, String> entry : entries) {
              map.put(entry.getKey(), entry.getValue());
            }
            return Maps.unmodifiableNavigableMap(map);
          }
        })
        .named("unmodifiableNavigableMap[SafeTreeMap]")
        .withFeatures(CollectionSize.ANY,
            MapFeature.ALLOWS_NULL_VALUES)
        .createTestSuite());
    suite.addTest(NavigableMapTestSuiteBuilder
        .using(new TestStringMapGenerator() {

          @Override
          protected Map<String, String> create(Entry<String, String>[] entries) {
            SafeTreeMap<String, String> map = new SafeTreeMap<String, String>();
            for (Entry<String, String> entry : entries) {
View Full Code Here

        return suite;
    }

    public Test testsForPauselessHashMap() {
        return MapTestSuiteBuilder
                .using(new TestStringMapGenerator() {
                    @Override
                    protected Map<String, String> create(
                            Map.Entry<String, String>[] entries) {
                        return toHashMap(entries);
                    }
View Full Code Here

  public static Test suite() {
    TestSuite suite = new TestSuite();

    suite.addTestSuite(ForwardingMapTest.class);
    suite.addTest(MapTestSuiteBuilder.using(new TestStringMapGenerator() {

      @Override protected Map<String, String> create(
          Entry<String, String>[] entries) {
        Map<String, String> map = Maps.newLinkedHashMap();
        for (Entry<String, String> entry : entries) {
          map.put(entry.getKey(), entry.getValue());
        }
        return new StandardImplForwardingMap<String, String>(map);
      }

    }).named("ForwardingMap[LinkedHashMap] with standard implementations")
        .withFeatures(CollectionSize.ANY, MapFeature.ALLOWS_NULL_VALUES,
            MapFeature.ALLOWS_NULL_KEYS, MapFeature.ALLOWS_ANY_NULL_QUERIES,
            MapFeature.GENERAL_PURPOSE,
            CollectionFeature.SUPPORTS_ITERATOR_REMOVE, CollectionFeature.KNOWN_ORDER)
        .createTestSuite());
    suite.addTest(MapTestSuiteBuilder.using(new TestStringMapGenerator() {

      @Override protected Map<String, String> create(
          Entry<String, String>[] entries) {
        ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
        for (Entry<String, String> entry : entries) {
View Full Code Here

    return suite;
  }
 
  static TestSuite filterMapSuite() {
    TestSuite suite = new TestSuite("FilterMap");
    suite.addTest(MapTestSuiteBuilder.using(new TestStringMapGenerator() {
        @Override
        protected Map<String, String> create(Entry<String, String>[] entries) {
          Map<String, String> map = Maps.newHashMap();
          putEntries(map, entries);
          map.putAll(ENTRIES_TO_FILTER);
          return Maps.filterKeys(map, FILTER_KEYS);
        }
      })
      .named("Maps.filterKeys[Map, Predicate]")
      .withFeatures(
          MapFeature.ALLOWS_NULL_KEYS,
          MapFeature.ALLOWS_NULL_VALUES,
          MapFeature.ALLOWS_ANY_NULL_QUERIES,
          MapFeature.GENERAL_PURPOSE,
          CollectionSize.ANY)
      .createTestSuite());
    suite.addTest(MapTestSuiteBuilder.using(new TestStringMapGenerator() {
        @Override
        protected Map<String, String> create(Entry<String, String>[] entries) {
          Map<String, String> map = Maps.newHashMap();
          putEntries(map, entries);
          map.putAll(ENTRIES_TO_FILTER);
          return Maps.filterValues(map, FILTER_VALUES);
        }
      })
      .named("Maps.filterValues[Map, Predicate]")
      .withFeatures(
          MapFeature.ALLOWS_NULL_KEYS,
          MapFeature.ALLOWS_NULL_VALUES,
          MapFeature.ALLOWS_ANY_NULL_QUERIES,
          MapFeature.GENERAL_PURPOSE,
          CollectionSize.ANY)
      .createTestSuite());
    suite.addTest(MapTestSuiteBuilder.using(new TestStringMapGenerator() {
        @Override
        protected Map<String, String> create(Entry<String, String>[] entries) {
          Map<String, String> map = Maps.newHashMap();
          putEntries(map, entries);
           map.putAll(ENTRIES_TO_FILTER);
          return Maps.filterEntries(map, FILTER_ENTRIES);
        }
      })
      .named("Maps.filterEntries[Map, Predicate]")
      .withFeatures(
          MapFeature.ALLOWS_NULL_KEYS,
          MapFeature.ALLOWS_NULL_VALUES,
          MapFeature.ALLOWS_ANY_NULL_QUERIES,
          MapFeature.GENERAL_PURPOSE,
          CollectionSize.ANY)
      .createTestSuite());
    suite.addTest(MapTestSuiteBuilder.using(new TestStringMapGenerator() {
        @Override
        protected Map<String, String> create(Entry<String, String>[] entries) {
          Map<String, String> map = Maps.newHashMap();
          putEntries(map, entries);
          map.putAll(ENTRIES_TO_FILTER);
View Full Code Here

    return suite;
  }
 
  static TestSuite transformMapSuite() {
    TestSuite suite = new TestSuite("TransformMap");
    suite.addTest(MapTestSuiteBuilder.using(new TestStringMapGenerator() {
        @Override
        protected Map<String, String> create(Entry<String, String>[] entries) {
          Map<String, String> map = Maps.newLinkedHashMap();
          for (Entry<String, String> entry : entries) {
            map.put(entry.getKey(), encode(entry.getValue()));
          }
          return Maps.transformValues(map, DECODE_FUNCTION);
        }
      })
      .named("Maps.transformValues[Map, Function]")
      .withFeatures(
          CollectionSize.ANY,
          CollectionFeature.KNOWN_ORDER,
          MapFeature.ALLOWS_NULL_KEYS,
          MapFeature.ALLOWS_ANY_NULL_QUERIES,
          MapFeature.SUPPORTS_REMOVE,
          CollectionFeature.SUPPORTS_ITERATOR_REMOVE)
      .createTestSuite());
    suite.addTest(MapTestSuiteBuilder.using(new TestStringMapGenerator() {
        @Override
        protected Map<String, String> create(Entry<String, String>[] entries) {
          Map<String, String> map = Maps.newLinkedHashMap();
          for (Entry<String, String> entry : entries) {
            map.put(entry.getKey(), encode(entry.getValue()));
View Full Code Here

  public static Test suite() {
    TestSuite suite = new TestSuite();

    suite.addTestSuite(ForwardingNavigableMapTest.class);
    suite.addTest(NavigableMapTestSuiteBuilder.using(new TestStringMapGenerator() {
      @Override protected Map<String, String> create(
          Entry<String, String>[] entries) {
        NavigableMap<String, String> map = new SafeTreeMap<String, String>();
        for (Entry<String, String> entry : entries) {
          map.put(entry.getKey(), entry.getValue());
View Full Code Here

TOP

Related Classes of com.google.common.collect.testing.TestStringMapGenerator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.