Add test for checkClasses bean

This commit is contained in:
Paul Campbell 2018-01-25 06:55:18 +00:00
parent 045f663ae5
commit fd63f94a27

View file

@ -4,8 +4,14 @@ import com.google.common.reflect.ClassPath;
import org.junit.Test; import org.junit.Test;
import java.io.IOException; import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
/** /**
* Tests for {@link BuilderConfiguration}. * Tests for {@link BuilderConfiguration}.
@ -21,4 +27,21 @@ public class BuilderConfigurationTest {
//then //then
assertThat(classPath).isNotNull(); assertThat(classPath).isNotNull();
} }
@Test
public void canGetCheckClasses() {
//given
final PackageScanner packageScanner = mock(PackageScanner.class);
final String checkstyleClass = "checkstyle class";
given(packageScanner.apply(RuleSource.CHECKSTYLE)).willReturn(Stream.of(checkstyleClass));
final String sevntuClass = "sevntu class";
given(packageScanner.apply(RuleSource.SEVNTU)).willReturn(Stream.of(sevntuClass));
//when
final Map<RuleSource, List<String>> checkClasses = new BuilderConfiguration().checkClasses(packageScanner);
//then
assertThat(checkClasses).containsOnlyKeys(RuleSource.values());
assertThat(checkClasses)
.containsEntry(RuleSource.CHECKSTYLE, Collections.singletonList(checkstyleClass))
.containsEntry(RuleSource.SEVNTU, Collections.singletonList(sevntuClass));
}
} }