mkodekar / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Small refactoring of MapTestSuiteBuilder which would ease extension #1801

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
diff --git 
a/guava-testlib/src/com/google/common/collect/testing/MapTestSuiteBuilder.java 
b/guava-testlib/src/com/google/common/collect/testing/MapTestSuiteBuilder.java
index f54596a..c8390f0 100644
--- 
a/guava-testlib/src/com/google/common/collect/testing/MapTestSuiteBuilder.java
+++ 
b/guava-testlib/src/com/google/common/collect/testing/MapTestSuiteBuilder.java
@@ -106,7 +106,7 @@ public class MapTestSuiteBuilder<K, V>
           .createTestSuite());
     }

-    derivedSuites.add(SetTestSuiteBuilder.using(
+    derivedSuites.add(createDerivedEntrySetSuite(
             new MapEntrySetGenerator<K, V>(parentBuilder.getSubjectGenerator()))
         .withFeatures(computeEntrySetFeatures(parentBuilder.getFeatures()))
         .named(parentBuilder.getName() + " entrySet")
@@ -120,7 +120,7 @@ public class MapTestSuiteBuilder<K, V>
         .suppressing(parentBuilder.getSuppressedTests())
         .createTestSuite());

-    derivedSuites.add(CollectionTestSuiteBuilder.using(
+    derivedSuites.add(createDerivedValueCollectionSuite(
             new MapValueCollectionGenerator<K, V>(
                 parentBuilder.getSubjectGenerator()))
         .named(parentBuilder.getName() + " values")
@@ -132,10 +132,20 @@ public class MapTestSuiteBuilder<K, V>
     return derivedSuites;
   }

+  protected SetTestSuiteBuilder<Map.Entry<K, V>> createDerivedEntrySetSuite(
+      TestSetGenerator<Map.Entry<K, V>> entrySetGenerator) {
+    return SetTestSuiteBuilder.using(entrySetGenerator);
+  }
+
   protected SetTestSuiteBuilder<K> createDerivedKeySetSuite(TestSetGenerator<K> keySetGenerator) {
     return SetTestSuiteBuilder.using(keySetGenerator);
   }

+  protected CollectionTestSuiteBuilder<V> createDerivedValueCollectionSuite(
+      TestCollectionGenerator<V> valueCollectionGenerator) {
+    return CollectionTestSuiteBuilder.using(valueCollectionGenerator);
+  }
+
   private static Set<Feature<?>> computeReserializedMapFeatures(
       Set<Feature<?>> mapFeatures) {
     Set<Feature<?>> derivedFeatures = Helpers.copyToSet(mapFeatures);

Original issue reported on code.google.com by leventov...@gmail.com on 13 Jul 2014 at 11:53

GoogleCodeExporter commented 9 years ago
Thanks. We'll probably do this. When we do, we should figure out whether our 
BiMapTestSuiteBuilder can take advantage.

Original comment by cpov...@google.com on 21 Jul 2014 at 6:50

GoogleCodeExporter commented 9 years ago
FYI I need this for 
https://github.com/OpenHFT/hftc/blob/3ba0ae7f660bd1c056d2b8065546a949062e46be/li
b/testing/src/main/javaTemplates/net/openhft/collect/testing/map/GuavaCharShortM
apTestSuiteBuilder.java#L57

Original comment by leventov...@gmail.com on 23 Jul 2014 at 7:28

GoogleCodeExporter commented 9 years ago
I submitted this internally yesterday, so we should have it mirrored out for 
you soon.

Original comment by cpov...@google.com on 23 Jul 2014 at 7:33

GoogleCodeExporter commented 9 years ago
Thank you Chris!

Original comment by leventov...@gmail.com on 23 Jul 2014 at 8:21

GoogleCodeExporter commented 9 years ago
This issue should be "fixed" now.

Original comment by leventov...@gmail.com on 19 Aug 2014 at 10:48

GoogleCodeExporter commented 9 years ago

Original comment by cpov...@google.com on 19 Aug 2014 at 10:51

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<issue id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:08

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:07