Add test for checkClasses bean
This commit is contained in:
parent
045f663ae5
commit
fd63f94a27
1 changed files with 23 additions and 0 deletions
|
@ -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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue