TestSuite computeMultimapGetTestSuite(
     FeatureSpecificTestSuiteBuilder<
             ?, ? extends OneSizeTestContainerGenerator<M, Map.Entry<K, V>>>
         parentBuilder) {
   return CollectionTestSuiteBuilder.using(
           new MultimapGetGenerator<K, V, M>(parentBuilder.getSubjectGenerator()))
       .withFeatures(computeMultimapGetFeatures(parentBuilder.getFeatures()))
       .named(parentBuilder.getName() + ".get[key]")
       .suppressing(parentBuilder.getSuppressedTests())
       .createTestSuite();
 }
 TestSuite computeMultimapAsMapGetTestSuite(
     FeatureSpecificTestSuiteBuilder<
             ?, ? extends OneSizeTestContainerGenerator<M, Map.Entry<K, V>>>
         parentBuilder) {
   Set<Feature<?>> features = computeMultimapAsMapGetFeatures(parentBuilder.getFeatures());
   if (Collections.disjoint(features, EnumSet.allOf(CollectionSize.class))) {
     return new TestSuite();
   } else {
     return CollectionTestSuiteBuilder.using(
             new MultimapAsMapGetGenerator<K, V, M>(parentBuilder.getSubjectGenerator()))
         .withFeatures(features)
         .named(parentBuilder.getName() + ".asMap[].get[key]")
         .suppressing(parentBuilder.getSuppressedTests())
         .createTestSuite();
   }
 }
 @GwtIncompatible("suite")
 private static Test testsForFilterAll() {
   return CollectionTestSuiteBuilder.using(
           new TestStringCollectionGenerator() {
             @Override
             public Collection<String> create(String[] elements) {
               List<String> unfiltered = newArrayList();
               Collections.addAll(unfiltered, elements);
               return Collections2.filter(unfiltered, NOT_YYY_ZZZ);
             }
           })
       .named("Collections2.filter")
       .withFeatures(
           CollectionFeature.SUPPORTS_ADD,
           CollectionFeature.SUPPORTS_REMOVE,
           CollectionFeature.ALLOWS_NULL_VALUES,
           CollectionFeature.KNOWN_ORDER,
           CollectionSize.ANY)
       .createTestSuite();
 }
 @GwtIncompatible("suite")
 private static Test testsForTransform() {
   return CollectionTestSuiteBuilder.using(
           new TestStringCollectionGenerator() {
             @Override
             public Collection<String> create(String[] elements) {
               List<String> list = newArrayList();
               for (String element : elements) {
                 list.add((element == null) ? null : "q" + element);
               }
               return Collections2.transform(list, REMOVE_FIRST_CHAR);
             }
           })
       .named("Collections2.transform")
       .withFeatures(
           CollectionFeature.REMOVE_OPERATIONS,
           CollectionFeature.ALLOWS_NULL_VALUES,
           CollectionFeature.KNOWN_ORDER,
           CollectionSize.ANY)
       .createTestSuite();
 }
 @GwtIncompatible("suite")
 private static Test testsForFilterNoNulls() {
   return CollectionTestSuiteBuilder.using(
           new TestStringCollectionGenerator() {
             @Override
             public Collection<String> create(String[] elements) {
               List<String> unfiltered = newArrayList();
               unfiltered.add("yyy");
               unfiltered.addAll(ImmutableList.copyOf(elements));
               unfiltered.add("zzz");
               return Collections2.filter(unfiltered, LENGTH_1);
             }
           })
       .named("Collections2.filter, no nulls")
       .withFeatures(
           CollectionFeature.SUPPORTS_ADD,
           CollectionFeature.SUPPORTS_REMOVE,
           CollectionFeature.ALLOWS_NULL_QUERIES,
           CollectionFeature.KNOWN_ORDER,
           CollectionSize.ANY)
       .createTestSuite();
 }
Exemplo n.º 6
0
  @GwtIncompatible // suite
  public static Test suite() {
    TestSuite suite = new TestSuite();
    suite.addTestSuite(ImmutableMapTest.class);

    suite.addTest(
        MapTestSuiteBuilder.using(new ImmutableMapGenerator())
            .withFeatures(
                CollectionSize.ANY,
                CollectionFeature.SERIALIZABLE_INCLUDING_VIEWS,
                CollectionFeature.KNOWN_ORDER,
                MapFeature.REJECTS_DUPLICATES_AT_CREATION,
                CollectionFeature.ALLOWS_NULL_QUERIES)
            .named("ImmutableMap")
            .createTestSuite());

    suite.addTest(
        MapTestSuiteBuilder.using(new ImmutableMapCopyOfGenerator())
            .withFeatures(
                CollectionSize.ANY,
                CollectionFeature.SERIALIZABLE_INCLUDING_VIEWS,
                CollectionFeature.KNOWN_ORDER,
                CollectionFeature.ALLOWS_NULL_QUERIES)
            .named("ImmutableMap.copyOf[Map]")
            .createTestSuite());

    suite.addTest(
        MapTestSuiteBuilder.using(new ImmutableMapCopyOfEntriesGenerator())
            .withFeatures(
                CollectionSize.ANY,
                MapFeature.REJECTS_DUPLICATES_AT_CREATION,
                CollectionFeature.SERIALIZABLE_INCLUDING_VIEWS,
                CollectionFeature.KNOWN_ORDER,
                CollectionFeature.ALLOWS_NULL_QUERIES)
            .named("ImmutableMap.copyOf[Iterable<Entry>]")
            .createTestSuite());

    suite.addTest(
        MapTestSuiteBuilder.using(new ImmutableMapCopyOfEnumMapGenerator())
            .withFeatures(
                CollectionSize.ANY,
                CollectionFeature.SERIALIZABLE_INCLUDING_VIEWS,
                CollectionFeature.KNOWN_ORDER,
                CollectionFeature.ALLOWS_NULL_QUERIES)
            .named("ImmutableMap.copyOf[EnumMap]")
            .createTestSuite());

    suite.addTest(
        CollectionTestSuiteBuilder.using(new ImmutableMapUnhashableValuesGenerator())
            .withFeatures(
                CollectionSize.ANY,
                CollectionFeature.KNOWN_ORDER,
                CollectionFeature.ALLOWS_NULL_QUERIES)
            .named("ImmutableMap.values, unhashable")
            .createTestSuite());

    suite.addTest(
        ListTestSuiteBuilder.using(new ImmutableMapKeyListGenerator())
            .named("ImmutableMap.keySet.asList")
            .withFeatures(
                CollectionSize.ANY,
                CollectionFeature.SERIALIZABLE,
                CollectionFeature.REJECTS_DUPLICATES_AT_CREATION,
                CollectionFeature.ALLOWS_NULL_QUERIES)
            .createTestSuite());

    suite.addTest(
        ListTestSuiteBuilder.using(new ImmutableMapEntryListGenerator())
            .named("ImmutableMap.entrySet.asList")
            .withFeatures(
                CollectionSize.ANY,
                CollectionFeature.SERIALIZABLE,
                CollectionFeature.REJECTS_DUPLICATES_AT_CREATION,
                CollectionFeature.ALLOWS_NULL_QUERIES)
            .createTestSuite());

    suite.addTest(
        ListTestSuiteBuilder.using(new ImmutableMapValueListGenerator())
            .named("ImmutableMap.values.asList")
            .withFeatures(
                CollectionSize.ANY,
                CollectionFeature.SERIALIZABLE,
                CollectionFeature.ALLOWS_NULL_QUERIES)
            .createTestSuite());

    return suite;
  }