public static void assertThatClassIsImmutable(Class<?> clazz) {
        final ImmutableClassChecker checker = new ImmutableClassChecker();
        if (!checker.isImmutableClass(clazz, false)) {
            final Description toDescription = new StringDescription();
            final Description mismatchDescription = new StringDescription();

            checker.describeTo(toDescription);
            checker.describeMismatch(mismatchDescription);
            final String reason =
                    "\n" +
                    "Expected: is \"" + toDescription.toString() + "\"\n" +
                    "    but : was \"" + mismatchDescription.toString() + "\"";

            throw new AssertionError(reason);
        }
    }
@Test
    public void testClassWithSetter() throws Exception {
        boolean gotException = false;
        try {
            assertThatClassIsImmutable(ClassWithSetter.class);
        } catch (AssertionError assertion) {
            assertThat(assertion.getMessage(),
                    containsString("a class with a setter named 'setX'"));
            gotException = true;
        }
        assertThat(gotException, is(true));
    }