Java 类com.google.common.collect.testing.SampleElements 实例源码

项目:guava-mock    文件:TestStringBiMapGenerator.java   
@Override
public SampleElements<Map.Entry<String, String>> samples() {
  return new SampleElements<Map.Entry<String, String>>(
      Helpers.mapEntry("one", "January"),
      Helpers.mapEntry("two", "February"),
      Helpers.mapEntry("three", "March"),
      Helpers.mapEntry("four", "April"),
      Helpers.mapEntry("five", "May"));
}
项目:guava-mock    文件:TestStringListMultimapGenerator.java   
@Override
public SampleElements<Map.Entry<String, String>> samples() {
  return new SampleElements<Map.Entry<String, String>>(
      Helpers.mapEntry("one", "January"),
      Helpers.mapEntry("two", "February"),
      Helpers.mapEntry("three", "March"),
      Helpers.mapEntry("four", "April"),
      Helpers.mapEntry("five", "May"));
}
项目:guava-mock    文件:SortedMapGenerators.java   
@Override
public SampleElements<Entry<String, Integer>> samples() {
  return new SampleElements<Entry<String, Integer>>(
      mapEntry("foo", 5),
      mapEntry("bar", 3),
      mapEntry("baz", 17),
      mapEntry("quux", 1),
      mapEntry("toaster", -2));
}
项目:guava-mock    文件:MapGenerators.java   
@Override
public SampleElements<Entry<String, Integer>> samples() {
  return new SampleElements<>(
      mapEntry("foo", 5),
      mapEntry("bar", 3),
      mapEntry("baz", 17),
      mapEntry("quux", 1),
      mapEntry("toaster", -2));
}
项目:guava-mock    文件:MapGenerators.java   
@Override
public SampleElements<Entry<String, Collection<Integer>>> samples() {
  return new SampleElements<>(
      mapEntry("one", ImmutableSet.of(10000)),
      mapEntry("two", ImmutableSet.of(-2000)),
      mapEntry("three", ImmutableSet.of(300)),
      mapEntry("four", ImmutableSet.of(-40)),
      mapEntry("five", ImmutableSet.of(5)));
}
项目:guava-mock    文件:DerivedGoogleCollectionGenerators.java   
public BiMapValueSetGenerator(
    OneSizeTestContainerGenerator<BiMap<K, V>, Entry<K, V>> mapGenerator) {
  this.mapGenerator = mapGenerator;
  final SampleElements<Map.Entry<K, V>> mapSamples = this.mapGenerator.samples();
  this.samples =
      new SampleElements<V>(
          mapSamples.e0().getValue(),
          mapSamples.e1().getValue(),
          mapSamples.e2().getValue(),
          mapSamples.e3().getValue(),
          mapSamples.e4().getValue());
}
项目:guava-mock    文件:TestStringSetMultimapGenerator.java   
@Override
public SampleElements<Map.Entry<String, String>> samples() {
  return new SampleElements<Map.Entry<String, String>>(
      Helpers.mapEntry("one", "January"),
      Helpers.mapEntry("two", "February"),
      Helpers.mapEntry("three", "March"),
      Helpers.mapEntry("four", "April"),
      Helpers.mapEntry("five", "May"));
}
项目:guava-mock    文件:MultimapTestSuiteBuilder.java   
@Override
public SampleElements<Entry<K, Collection<V>>> samples() {
  SampleElements<K> sampleKeys =
      ((TestMultimapGenerator<K, V, M>) multimapGenerator.getInnerGenerator()).sampleKeys();
  SampleElements<V> sampleValues =
      ((TestMultimapGenerator<K, V, M>) multimapGenerator.getInnerGenerator()).sampleValues();
  return new SampleElements<Entry<K, Collection<V>>>(
      mapEntry(sampleKeys.e0(), createCollection(sampleValues.e0())),
      mapEntry(sampleKeys.e1(), createCollection(sampleValues.e1())),
      mapEntry(sampleKeys.e2(), createCollection(sampleValues.e2())),
      mapEntry(sampleKeys.e3(), createCollection(sampleValues.e3())),
      mapEntry(sampleKeys.e4(), createCollection(sampleValues.e4())));
}
项目:googles-monorepo-demo    文件:ImmutableMultimapTest.java   
public void testUnhashableMixedValues() {
  SampleElements<UnhashableObject> unhashables = new Unhashables();
  Multimap<Integer, Object> multimap = ImmutableMultimap.<Integer, Object>of(
      0, unhashables.e0(), 2, "hey you", 0, unhashables.e1());
  assertEquals(2, multimap.get(0).size());
  assertTrue(multimap.get(0).contains(unhashables.e0()));
  assertTrue(multimap.get(0).contains(unhashables.e1()));
  assertTrue(multimap.get(2).contains("hey you"));
}
项目:guava-mock    文件:TableCollectionTest.java   
@Override
public SampleElements<Cell<String, Integer, Character>> samples() {
  return new SampleElements<Cell<String, Integer, Character>>(
      Tables.immutableCell("bar", 1, 'a'),
      Tables.immutableCell("bar", 2, 'b'),
      Tables.immutableCell("foo", 3, 'c'),
      Tables.immutableCell("bar", 1, 'b'),
      Tables.immutableCell("cat", 2, 'b'));
}
项目:guava-mock    文件:MultimapsCollectionTest.java   
@Override
public SampleElements<Entry<String, String>> samples() {
  return new SampleElements<Entry<String, String>>(
      mapEntry("one", "january"),
      mapEntry("two", "february"),
      mapEntry("three", "march"),
      mapEntry("four", "april"),
      mapEntry("five", "may"));
}
项目:guava-mock    文件:MultimapsCollectionTest.java   
@Override
public SampleElements<Entry<String, Integer>> samples() {
  return new SampleElements<Entry<String, Integer>>(
      mapEntry("one", 114),
      mapEntry("two", 37),
      mapEntry("three", 42),
      mapEntry("four", 19),
      mapEntry("five", 82));
}
项目:guava-mock    文件:ImmutableClassToInstanceMapTest.java   
@Override
public SampleElements<Entry<Class, Impl>> samples() {
  return new SampleElements<Entry<Class, Impl>>(
      immutableEntry((Class) One.class, new Impl(1)),
      immutableEntry((Class) Two.class, new Impl(2)),
      immutableEntry((Class) Three.class, new Impl(3)),
      immutableEntry((Class) Four.class, new Impl(4)),
      immutableEntry((Class) Five.class, new Impl(5)));
}
项目:guava-mock    文件:EnumHashBiMapTest.java   
@Override
public SampleElements<Entry<Country, String>> samples() {
  return new SampleElements<Entry<Country, String>>(
      Maps.immutableEntry(Country.CANADA, "DOLLAR"),
      Maps.immutableEntry(Country.CHILE, "PESO"),
      Maps.immutableEntry(Country.UK, "POUND"),
      Maps.immutableEntry(Country.JAPAN, "YEN"),
      Maps.immutableEntry(Country.SWITZERLAND, "FRANC"));
}
项目:guava-mock    文件:EnumBiMapTest.java   
@Override
public SampleElements<Entry<Country, Currency>> samples() {
  return new SampleElements<Entry<Country, Currency>>(
      Helpers.mapEntry(Country.CANADA, Currency.DOLLAR),
      Helpers.mapEntry(Country.CHILE, Currency.PESO),
      Helpers.mapEntry(Country.UK, Currency.POUND),
      Helpers.mapEntry(Country.JAPAN, Currency.YEN),
      Helpers.mapEntry(Country.SWITZERLAND, Currency.FRANC));
}
项目:guava-mock    文件:ImmutableRangeSetTest.java   
@Override
public SampleElements<BigInteger> samples() {
  return new SampleElements<BigInteger>(
      BigInteger.valueOf(1),
      BigInteger.valueOf(4),
      BigInteger.valueOf(3),
      BigInteger.valueOf(2),
      BigInteger.valueOf(5));
}
项目:guava-mock    文件:ImmutableMultimapTest.java   
public void testUnhashableSingletonValue() {
  SampleElements<UnhashableObject> unhashables = new Unhashables();
  Multimap<Integer, UnhashableObject> multimap = ImmutableMultimap.of(
      0, unhashables.e0());
  assertEquals(1, multimap.get(0).size());
  assertTrue(multimap.get(0).contains(unhashables.e0()));
}
项目:guava-mock    文件:ImmutableMultimapTest.java   
public void testUnhashableMixedValues() {
  SampleElements<UnhashableObject> unhashables = new Unhashables();
  Multimap<Integer, Object> multimap = ImmutableMultimap.<Integer, Object>of(
      0, unhashables.e0(), 2, "hey you", 0, unhashables.e1());
  assertEquals(2, multimap.get(0).size());
  assertTrue(multimap.get(0).contains(unhashables.e0()));
  assertTrue(multimap.get(0).contains(unhashables.e1()));
  assertTrue(multimap.get(2).contains("hey you"));
}
项目:guava-mock    文件:ImmutableTypeToInstanceMapTest.java   
@Override
public SampleElements<Entry<TypeToken, Object>> samples() {
  return new SampleElements<Entry<TypeToken, Object>>(
      entry(TypeToken.of(Integer.class), 0),
      entry(TypeToken.of(Number.class), 1),
      entry(new TypeToken<ImmutableList<Integer>>() {}, ImmutableList.of(2)),
      entry(new TypeToken<int[]>() {}, new int[] {3}),
      entry(new TypeToken<Iterable<?>>() {}, ImmutableList.of("4")));
}
项目:googles-monorepo-demo    文件:ImmutableMultimapTest.java   
public void testUnhashableSingletonValue() {
  SampleElements<UnhashableObject> unhashables = new Unhashables();
  Multimap<Integer, UnhashableObject> multimap = ImmutableMultimap.of(
      0, unhashables.e0());
  assertEquals(1, multimap.get(0).size());
  assertTrue(multimap.get(0).contains(unhashables.e0()));
}
项目:googles-monorepo-demo    文件:TestStringListMultimapGenerator.java   
@Override
public SampleElements<Map.Entry<String, String>> samples() {
  return new SampleElements<Map.Entry<String, String>>(
      Helpers.mapEntry("one", "January"),
      Helpers.mapEntry("two", "February"),
      Helpers.mapEntry("three", "March"),
      Helpers.mapEntry("four", "April"),
      Helpers.mapEntry("five", "May"));
}
项目:googles-monorepo-demo    文件:SortedMapGenerators.java   
@Override
public SampleElements<Entry<String, Integer>> samples() {
  return new SampleElements<Entry<String, Integer>>(
      mapEntry("foo", 5),
      mapEntry("bar", 3),
      mapEntry("baz", 17),
      mapEntry("quux", 1),
      mapEntry("toaster", -2));
}
项目:googles-monorepo-demo    文件:MapGenerators.java   
@Override
public SampleElements<Entry<String, Integer>> samples() {
  return new SampleElements<Entry<String, Integer>>(
      mapEntry("foo", 5),
      mapEntry("bar", 3),
      mapEntry("baz", 17),
      mapEntry("quux", 1),
      mapEntry("toaster", -2));
}
项目:googles-monorepo-demo    文件:DerivedGoogleCollectionGenerators.java   
public BiMapValueSetGenerator(
    OneSizeTestContainerGenerator<BiMap<K, V>, Entry<K, V>> mapGenerator) {
  this.mapGenerator = mapGenerator;
  final SampleElements<Map.Entry<K, V>> mapSamples = this.mapGenerator.samples();
  this.samples =
      new SampleElements<V>(
          mapSamples.e0().getValue(),
          mapSamples.e1().getValue(),
          mapSamples.e2().getValue(),
          mapSamples.e3().getValue(),
          mapSamples.e4().getValue());
}
项目:googles-monorepo-demo    文件:ImmutableRangeSetTest.java   
@Override
public SampleElements<BigInteger> samples() {
  return new SampleElements<BigInteger>(
      BigInteger.valueOf(1),
      BigInteger.valueOf(4),
      BigInteger.valueOf(3),
      BigInteger.valueOf(2),
      BigInteger.valueOf(5));
}
项目:googles-monorepo-demo    文件:TestStringSetMultimapGenerator.java   
@Override
public SampleElements<Map.Entry<String, String>> samples() {
  return new SampleElements<Map.Entry<String, String>>(
      Helpers.mapEntry("one", "January"),
      Helpers.mapEntry("two", "February"),
      Helpers.mapEntry("three", "March"),
      Helpers.mapEntry("four", "April"),
      Helpers.mapEntry("five", "May"));
}
项目:googles-monorepo-demo    文件:MultimapTestSuiteBuilder.java   
@Override
public SampleElements<Entry<K, Collection<V>>> samples() {
  SampleElements<K> sampleKeys =
      ((TestMultimapGenerator<K, V, M>) multimapGenerator.getInnerGenerator()).sampleKeys();
  SampleElements<V> sampleValues =
      ((TestMultimapGenerator<K, V, M>) multimapGenerator.getInnerGenerator()).sampleValues();
  return new SampleElements<Entry<K, Collection<V>>>(
      mapEntry(sampleKeys.e0(), createCollection(sampleValues.e0())),
      mapEntry(sampleKeys.e1(), createCollection(sampleValues.e1())),
      mapEntry(sampleKeys.e2(), createCollection(sampleValues.e2())),
      mapEntry(sampleKeys.e3(), createCollection(sampleValues.e3())),
      mapEntry(sampleKeys.e4(), createCollection(sampleValues.e4())));
}
项目:googles-monorepo-demo    文件:ImmutableTypeToInstanceMapTest.java   
@Override
public SampleElements<Entry<TypeToken, Object>> samples() {
  return new SampleElements<Entry<TypeToken, Object>>(
      entry(TypeToken.of(Integer.class), 0),
      entry(TypeToken.of(Number.class), 1),
      entry(new TypeToken<ImmutableList<Integer>>() {}, ImmutableList.of(2)),
      entry(new TypeToken<int[]>() {}, new int[] {3}),
      entry(new TypeToken<Iterable<?>>() {}, ImmutableList.of("4")));
}
项目:googles-monorepo-demo    文件:TableCollectionTest.java   
@Override
public SampleElements<Cell<String, Integer, Character>> samples() {
  return new SampleElements<Cell<String, Integer, Character>>(
      Tables.immutableCell("bar", 1, 'a'),
      Tables.immutableCell("bar", 2, 'b'),
      Tables.immutableCell("foo", 3, 'c'),
      Tables.immutableCell("bar", 1, 'b'),
      Tables.immutableCell("cat", 2, 'b'));
}
项目:googles-monorepo-demo    文件:MultimapsCollectionTest.java   
@Override
public SampleElements<Entry<String, String>> samples() {
  return new SampleElements<Entry<String, String>>(
      mapEntry("one", "january"),
      mapEntry("two", "february"),
      mapEntry("three", "march"),
      mapEntry("four", "april"),
      mapEntry("five", "may"));
}
项目:googles-monorepo-demo    文件:MultimapsCollectionTest.java   
@Override
public SampleElements<Entry<String, Integer>> samples() {
  return new SampleElements<Entry<String, Integer>>(
      mapEntry("one", 114),
      mapEntry("two", 37),
      mapEntry("three", 42),
      mapEntry("four", 19),
      mapEntry("five", 82));
}
项目:googles-monorepo-demo    文件:ImmutableClassToInstanceMapTest.java   
@Override
public SampleElements<Entry<Class, Impl>> samples() {
  return new SampleElements<Entry<Class, Impl>>(
      immutableEntry((Class) One.class, new Impl(1)),
      immutableEntry((Class) Two.class, new Impl(2)),
      immutableEntry((Class) Three.class, new Impl(3)),
      immutableEntry((Class) Four.class, new Impl(4)),
      immutableEntry((Class) Five.class, new Impl(5)));
}
项目:googles-monorepo-demo    文件:EnumBiMapTest.java   
@Override
public SampleElements<Entry<Country, Currency>> samples() {
  return new SampleElements<Entry<Country, Currency>>(
      Helpers.mapEntry(Country.CANADA, Currency.DOLLAR),
      Helpers.mapEntry(Country.CHILE, Currency.PESO),
      Helpers.mapEntry(Country.UK, Currency.POUND),
      Helpers.mapEntry(Country.JAPAN, Currency.YEN),
      Helpers.mapEntry(Country.SWITZERLAND, Currency.FRANC));
}
项目:guava-mock    文件:TestEnumMultisetGenerator.java   
@Override
public SampleElements<AnEnum> samples() {
  return new Enums();
}
项目:guava-mock    文件:TestStringListMultimapGenerator.java   
@Override
public SampleElements<String> sampleKeys() {
  return new SampleElements<String>("one", "two", "three", "four", "five");
}
项目:guava-mock    文件:TestStringListMultimapGenerator.java   
@Override
public SampleElements<String> sampleValues() {
  return new SampleElements<String>("January", "February", "March", "April", "May");
}
项目:guava-mock    文件:MultisetTestSuiteBuilder.java   
@Override
public SampleElements<E> samples() {
  return gen.samples();
}
项目:guava-mock    文件:MultisetTestSuiteBuilder.java   
@Override
public SampleElements<E> samples() {
  return gen.samples();
}
项目:guava-mock    文件:TestStringMultisetGenerator.java   
@Override
public SampleElements<String> samples() {
  return new Strings();
}
项目:guava-mock    文件:SortedMultisetTestSuiteBuilder.java   
private TestSuite createSubMultisetSuite(
    SortedMultisetTestSuiteBuilder<E> parentBuilder, final Bound from, final Bound to) {
  final TestMultisetGenerator<E> delegate =
      (TestMultisetGenerator<E>) parentBuilder.getSubjectGenerator();

  Set<Feature<?>> features = new HashSet<Feature<?>>();
  features.add(NoRecurse.SUBMULTISET);
  features.add(RESTRICTS_ELEMENTS);
  features.addAll(parentBuilder.getFeatures());

  if (!features.remove(SERIALIZABLE_INCLUDING_VIEWS)) {
    features.remove(SERIALIZABLE);
  }

  SortedMultiset<E> emptyMultiset = (SortedMultiset<E>) delegate.create();
  final Comparator<? super E> comparator = emptyMultiset.comparator();
  SampleElements<E> samples = delegate.samples();
  @SuppressWarnings("unchecked")
  List<E> samplesList =
      Arrays.asList(samples.e0(), samples.e1(), samples.e2(), samples.e3(), samples.e4());

  Collections.sort(samplesList, comparator);
  final E firstInclusive = samplesList.get(0);
  final E lastInclusive = samplesList.get(samplesList.size() - 1);

  return SortedMultisetTestSuiteBuilder.using(
          new ForwardingTestMultisetGenerator<E>(delegate) {
            @Override
            public SortedMultiset<E> create(Object... entries) {
              @SuppressWarnings("unchecked")
              // we dangerously assume E is a string
              List<E> extremeValues = (List) getExtremeValues();
              @SuppressWarnings("unchecked")
              // map generators must past entry objects
              List<E> normalValues = (List) Arrays.asList(entries);

              // prepare extreme values to be filtered out of view
              Collections.sort(extremeValues, comparator);
              E firstExclusive = extremeValues.get(1);
              E lastExclusive = extremeValues.get(2);
              if (from == Bound.NO_BOUND) {
                extremeValues.remove(0);
                extremeValues.remove(0);
              }
              if (to == Bound.NO_BOUND) {
                extremeValues.remove(extremeValues.size() - 1);
                extremeValues.remove(extremeValues.size() - 1);
              }

              // the regular values should be visible after filtering
              List<E> allEntries = new ArrayList<E>();
              allEntries.addAll(extremeValues);
              allEntries.addAll(normalValues);
              SortedMultiset<E> multiset =
                  (SortedMultiset<E>) delegate.create(allEntries.toArray());

              // call the smallest subMap overload that filters out the extreme
              // values
              if (from == Bound.INCLUSIVE) {
                multiset = multiset.tailMultiset(firstInclusive, BoundType.CLOSED);
              } else if (from == Bound.EXCLUSIVE) {
                multiset = multiset.tailMultiset(firstExclusive, BoundType.OPEN);
              }

              if (to == Bound.INCLUSIVE) {
                multiset = multiset.headMultiset(lastInclusive, BoundType.CLOSED);
              } else if (to == Bound.EXCLUSIVE) {
                multiset = multiset.headMultiset(lastExclusive, BoundType.OPEN);
              }

              return multiset;
            }
          })
      .named(parentBuilder.getName() + " subMultiset " + from + "-" + to)
      .withFeatures(features)
      .suppressing(parentBuilder.getSuppressedTests())
      .createTestSuite();
}