Skip to content

Commit

Permalink
Rename CanBeTestClass to IsPotentialTestClass
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Nov 20, 2015
1 parent 22ba7b7 commit f8c120e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
Expand Up @@ -21,8 +21,8 @@
import org.junit.gen5.commons.util.ObjectUtils;
import org.junit.gen5.commons.util.Preconditions;
import org.junit.gen5.commons.util.ReflectionUtils;
import org.junit.gen5.engine.junit5.testers.CanBeTestClass;
import org.junit.gen5.engine.junit5.testers.IsNestedTestClass;
import org.junit.gen5.engine.junit5.testers.IsPotentialTestClass;
import org.junit.gen5.engine.junit5.testers.IsTestMethod;

/**
Expand All @@ -32,7 +32,7 @@ class JUnit5TestableFactory {

private static final String SEPARATORS = ":@#";

private CanBeTestClass canBeTestClass = new CanBeTestClass();
private IsPotentialTestClass isPotentialTestClass = new IsPotentialTestClass();
private IsNestedTestClass isNestedTestClass = new IsNestedTestClass();
private IsTestMethod isTestMethod = new IsTestMethod();

Expand All @@ -47,7 +47,7 @@ JUnit5Testable fromUniqueId(String uniqueId, String engineId) {
JUnit5Testable fromClass(Class<?> clazz, String engineId) {
Preconditions.notNull(clazz, "clazz must not be null");
Preconditions.notBlank(engineId, "Engine ID must not be null or empty");
if (canBeTestClass.test(clazz)) {
if (isPotentialTestClass.test(clazz)) {
String uniqueId = engineId + ":" + clazz.getName();
return new JUnit5Class(uniqueId, clazz);
}
Expand Down
Expand Up @@ -11,7 +11,8 @@
package org.junit.gen5.engine.junit5.testers;

import static org.junit.gen5.commons.util.AnnotationUtils.isAnnotated;
import static org.junit.gen5.commons.util.ReflectionUtils.*;
import static org.junit.gen5.commons.util.ReflectionUtils.isPrivate;
import static org.junit.gen5.commons.util.ReflectionUtils.isStatic;

import java.util.function.Predicate;

Expand All @@ -24,15 +25,15 @@
public class IsNestedTestClass implements Predicate<Class<?>> {

@Override
public boolean test(Class<?> nestedClassCandidate) {
public boolean test(Class<?> candidate) {
//please do not collapse into single return
if (isStatic(nestedClassCandidate))
if (isStatic(candidate))
return false;
if (isPrivate(nestedClassCandidate))
if (isPrivate(candidate))
return false;
if (!nestedClassCandidate.isMemberClass())
if (!candidate.isMemberClass())
return false;
return isAnnotated(nestedClassCandidate, Nested.class);
return isAnnotated(candidate, Nested.class);
}

}
Expand Up @@ -18,7 +18,7 @@
/**
* @since 5.0
*/
public class CanBeTestClass implements Predicate<Class<?>> {
public class IsPotentialTestClass implements Predicate<Class<?>> {

@Override
public boolean test(Class<?> candidate) {
Expand Down
Expand Up @@ -23,15 +23,15 @@ public class IsTestClassWithTests implements Predicate<Class<?>> {

private static final IsTestMethod isTestMethod = new IsTestMethod();

private static final CanBeTestClass canBeTestClass = new CanBeTestClass();
private static final IsPotentialTestClass isPotentialTestClass = new IsPotentialTestClass();

@Override
public boolean test(Class<?> testClassCandidate) {
return canBeTestClass.test(testClassCandidate) && hasTestMethods(testClassCandidate);
public boolean test(Class<?> candidate) {
return isPotentialTestClass.test(candidate) && hasTestMethods(candidate);
}

private boolean hasTestMethods(Class<?> testClassCandidate) {
return !ReflectionUtils.findMethods(testClassCandidate, isTestMethod, HierarchyDown).isEmpty();
private boolean hasTestMethods(Class<?> candidate) {
return !ReflectionUtils.findMethods(candidate, isTestMethod, HierarchyDown).isEmpty();
}

}

0 comments on commit f8c120e

Please sign in to comment.