org.mutabilitydetector.unittesting
Class MutabilityAsserter

java.lang.Object
  extended by org.mutabilitydetector.unittesting.MutabilityAsserter

public class MutabilityAsserter
extends Object

Performs Mutability Detector's analysis and produces unit-test-friendly AssertionError if the result is not as expected.

Instances of this class provide the methods accessed by MutabilityAssert. More detailed documentation can be found there.


Method Summary
 void assertImmutable(Class<?> expectedImmutableClass)
           
 void assertInstancesOf(Class<?> clazz, org.hamcrest.Matcher<AnalysisResult> mutabilityMatcher)
           
 void assertInstancesOf(Class<?> clazz, org.hamcrest.Matcher<AnalysisResult> mutabilityMatcher, Iterable<org.hamcrest.Matcher<MutableReasonDetail>> allowingAll)
           
 void assertInstancesOf(Class<?> clazz, org.hamcrest.Matcher<AnalysisResult> mutabilityMatcher, org.hamcrest.Matcher<MutableReasonDetail> allowing)
           
 void assertInstancesOf(Class<?> clazz, org.hamcrest.Matcher<AnalysisResult> mutabilityMatcher, org.hamcrest.Matcher<MutableReasonDetail> allowingFirst, org.hamcrest.Matcher<MutableReasonDetail> allowingSecond)
           
 void assertInstancesOf(Class<?> clazz, org.hamcrest.Matcher<AnalysisResult> mutabilityMatcher, org.hamcrest.Matcher<MutableReasonDetail> allowingFirst, org.hamcrest.Matcher<MutableReasonDetail> allowingSecond, org.hamcrest.Matcher<MutableReasonDetail> allowingThird)
           
 void assertInstancesOf(Class<?> clazz, org.hamcrest.Matcher<AnalysisResult> mutabilityMatcher, org.hamcrest.Matcher<MutableReasonDetail> allowingFirst, org.hamcrest.Matcher<MutableReasonDetail> allowingSecond, org.hamcrest.Matcher<MutableReasonDetail> allowingThird, org.hamcrest.Matcher<MutableReasonDetail>... allowingRest)
           
static MutabilityAsserter configured(Configuration configuration)
          Create a new asserter with an existing Configuration.
static MutabilityAsserter configured(ConfigurationBuilder configuration)
          Create a new asserter with a Configuration as built by the given ConfigurationBuilder.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

configured

public static MutabilityAsserter configured(Configuration configuration)
Create a new asserter with an existing Configuration.

Example:


 MutabilityAsserter.configured(MyConfigurations.DEFAULT_CONFIGURATIONS);
 

See Also:
Configurations, Configurations.JDK_CONFIGURATION, Configurations.NO_CONFIGURATION, Configurations.OUT_OF_THE_BOX_CONFIGURATION

configured

public static MutabilityAsserter configured(ConfigurationBuilder configuration)
Create a new asserter with a Configuration as built by the given ConfigurationBuilder.

Use this method when you want to build a one-time Configuration inline..

Example:

 
  MutabilityAsserter.configured(new ConfigurationBuilder() { 
   @Override public void configure() {
     hardcodeAsDefinitelyImmutable(ActuallyImmutable.class); 
   }
 });
 
 


assertImmutable

public void assertImmutable(Class<?> expectedImmutableClass)
See Also:
MutabilityAssert.assertImmutable(Class)

assertInstancesOf

public void assertInstancesOf(Class<?> clazz,
                              org.hamcrest.Matcher<AnalysisResult> mutabilityMatcher)
See Also:
MutabilityAssert.assertInstancesOf(Class, Matcher)

assertInstancesOf

public void assertInstancesOf(Class<?> clazz,
                              org.hamcrest.Matcher<AnalysisResult> mutabilityMatcher,
                              org.hamcrest.Matcher<MutableReasonDetail> allowing)
See Also:
MutabilityAssert.assertInstancesOf(Class, Matcher, Matcher)

assertInstancesOf

public void assertInstancesOf(Class<?> clazz,
                              org.hamcrest.Matcher<AnalysisResult> mutabilityMatcher,
                              org.hamcrest.Matcher<MutableReasonDetail> allowingFirst,
                              org.hamcrest.Matcher<MutableReasonDetail> allowingSecond)
See Also:
MutabilityAssert.assertInstancesOf(Class, Matcher, Matcher, Matcher)

assertInstancesOf

public void assertInstancesOf(Class<?> clazz,
                              org.hamcrest.Matcher<AnalysisResult> mutabilityMatcher,
                              org.hamcrest.Matcher<MutableReasonDetail> allowingFirst,
                              org.hamcrest.Matcher<MutableReasonDetail> allowingSecond,
                              org.hamcrest.Matcher<MutableReasonDetail> allowingThird)
See Also:
MutabilityAssert.assertInstancesOf(Class, Matcher, Matcher, Matcher, Matcher)

assertInstancesOf

public void assertInstancesOf(Class<?> clazz,
                              org.hamcrest.Matcher<AnalysisResult> mutabilityMatcher,
                              org.hamcrest.Matcher<MutableReasonDetail> allowingFirst,
                              org.hamcrest.Matcher<MutableReasonDetail> allowingSecond,
                              org.hamcrest.Matcher<MutableReasonDetail> allowingThird,
                              org.hamcrest.Matcher<MutableReasonDetail>... allowingRest)
See Also:
MutabilityAssert.assertInstancesOf(Class, Matcher, Matcher, Matcher, Matcher, Matcher...)

assertInstancesOf

public void assertInstancesOf(Class<?> clazz,
                              org.hamcrest.Matcher<AnalysisResult> mutabilityMatcher,
                              Iterable<org.hamcrest.Matcher<MutableReasonDetail>> allowingAll)
See Also:
MutabilityAssert.assertInstancesOf(Class, Matcher, Iterable)


Copyright © 2013. All Rights Reserved.