Skip to content

Instantly share code, notes, and snippets.

@neomatrix369
Created December 27, 2012 13:18
Show Gist options
  • Save neomatrix369/4388331 to your computer and use it in GitHub Desktop.
Save neomatrix369/4388331 to your computer and use it in GitHub Desktop.
Added a test and extended CanSubclassCheckerTest in src/test/java/org/mutabilitydetector/benchmarks/CanSubclassCheckerTest.java b/src/test/java/org/mutabilitydetector/benchmarks/CanSubclassCheckerTest.java
diff --git a/src/test/java/org/mutabilitydetector/benchmarks/CanSubclassCheckerTest.java b/src/test/java/org/mutabilitydetector/benchmarks/CanSubclassCheckerTest.java
index 988c019..bd99158 100644
--- a/src/test/java/org/mutabilitydetector/benchmarks/CanSubclassCheckerTest.java
+++ b/src/test/java/org/mutabilitydetector/benchmarks/CanSubclassCheckerTest.java
@@ -42,6 +42,7 @@ import org.mutabilitydetector.benchmarks.sealed.SealedImmutable;
import org.mutabilitydetector.benchmarks.types.EnumType;
import org.mutabilitydetector.checkers.CanSubclassChecker;
import org.mutabilitydetector.locations.ClassLocation;
+import org.mutabilitydetector.unittesting.MutabilityAssert;
@RunWith(Theories.class)
public class CanSubclassCheckerTest {
@@ -59,6 +60,7 @@ public class CanSubclassCheckerTest {
AnalysisResultTheory.of(HasFinalFieldsAndADefaultConstructor.class, NOT_IMMUTABLE),
AnalysisResultTheory.of(IsFinalAndHasOnlyPrivateConstructors.class, IMMUTABLE),
AnalysisResultTheory.of(ImmutableByHavingOnlyPrivateConstructors.class, IMMUTABLE),
+ AnalysisResultTheory.of(ImmutableByHavingOnlyAPrivateConstructorUsingTheBuilderPattern.class, IMMUTABLE),
};
@Theory
@@ -90,4 +92,8 @@ public class CanSubclassCheckerTest {
assertThat(location.typeName(), is(MutableByNotBeingFinalClass.class.getName()));
}
+ @Test
+ public void privateConstructorsUsingBuilderPatternAreImmutable() throws Exception {
+ MutabilityAssert.assertImmutable(ImmutableByHavingOnlyAPrivateConstructorUsingTheBuilderPattern.class);
+ }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment