package org.mutabilitydetector;

/*
 * #%L
 * MutabilityDetector
 * %%
 * Copyright (C) 2008 - 2015 Graham Allan
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

import org.junit.Test;
import org.mutabilitydetector.classpath.ClassPathScanner;

import java.util.Set;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;

public class ClassPathScannerTest {

    @Test
    public void scanClassPath() throws Exception {
        Set<Class<?>> immutableClasses = ClassPathScanner.findImmutableClasses("org.mutabilitydetector");

        assertThat(immutableClasses, notNullValue());
        assertThat(immutableClasses.size() > 0, is(true));
    }
}
package org.mutabilitydetector;

/*
 * #%L
 * MutabilityDetector
 * %%
 * Copyright (C) 2008 - 2015 Graham Allan
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

import org.junit.Test;
import org.mutabilitydetector.benchmarks.ImmutableExample;
import org.mutabilitydetector.benchmarks.settermethod.MutableByHavingSetterMethod;
import org.mutabilitydetector.classpath.ClassPathScanner;

import java.util.Set;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.not;

public class ClassPathScannerTest {

    @Test
    public void scanClassPath() throws Exception {
        Set<Class<?>> immutableClasses = ClassPathScanner.findImmutableClasses("org.mutabilitydetector");

        assertThat(immutableClasses, hasItem(ImmutableExample.class));
        assertThat(immutableClasses, not(hasItem(MutableByHavingSetterMethod.class)));
    }
}
Strengthen the unit test for ClassPathScanner.
Strengthen the unit test for ClassPathScanner.

Show that the classes returned will contain at least one of the classes annotated with immutable, and doesn't happen to pick up a mutable class on the same classpath.

/cc @lasombra
