Search in sources :

Example 1 with BaseTest

use of org.apache.drill.test.BaseTest in project drill by apache.

the class TestforBaseTestInheritance method verifyInheritance.

@Test
@Category(UnlikelyTest.class)
public void verifyInheritance() {
    // Get all BaseTest inheritors
    Reflections reflections = new Reflections("org.apache.drill", new SubTypesScanner(false));
    Set<Class<? extends BaseTest>> baseTestInheritors = reflections.getSubTypesOf(BaseTest.class);
    // Get all tests that are not inherited from BaseTest
    Set<String> testClasses = reflections.getSubTypesOf(Object.class).stream().filter(c -> !c.isInterface()).filter(c -> c.getSimpleName().toLowerCase().contains("test")).filter(c -> Arrays.stream(c.getDeclaredMethods()).anyMatch(m -> m.getAnnotation(Test.class) != null)).filter(c -> !baseTestInheritors.contains(c)).map(Class::getName).collect(Collectors.toSet());
    Assert.assertEquals("Found test classes that are not inherited from BaseTest:", Collections.emptySet(), testClasses);
}
Also used : BaseTest(org.apache.drill.test.BaseTest) Arrays(java.util.Arrays) UnlikelyTest(org.apache.drill.categories.UnlikelyTest) Set(java.util.Set) Test(org.junit.Test) Reflections(org.reflections.Reflections) Assert(org.junit.Assert) Category(org.junit.experimental.categories.Category) Collections(java.util.Collections) Collectors(java.util.stream.Collectors) SubTypesScanner(org.reflections.scanners.SubTypesScanner) SubTypesScanner(org.reflections.scanners.SubTypesScanner) BaseTest(org.apache.drill.test.BaseTest) Reflections(org.reflections.Reflections) Category(org.junit.experimental.categories.Category) BaseTest(org.apache.drill.test.BaseTest) UnlikelyTest(org.apache.drill.categories.UnlikelyTest) Test(org.junit.Test)

Aggregations

Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 UnlikelyTest (org.apache.drill.categories.UnlikelyTest)1 BaseTest (org.apache.drill.test.BaseTest)1 Assert (org.junit.Assert)1 Test (org.junit.Test)1 Category (org.junit.experimental.categories.Category)1 Reflections (org.reflections.Reflections)1 SubTypesScanner (org.reflections.scanners.SubTypesScanner)1