junitparams.internal.parameters.ParametersFromTestClassMethod Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of JUnitParams Show documentation
Show all versions of JUnitParams Show documentation
Better parameterised tests for JUnit
package junitparams.internal.parameters;
import javax.lang.model.type.NullType;
import org.junit.runners.model.FrameworkMethod;
import junitparams.Parameters;
class ParametersFromTestClassMethod implements ParametrizationStrategy {
private ParamsFromMethodCommon paramsFromMethodCommon;
private Class> testClass;
private Parameters annotation;
ParametersFromTestClassMethod(FrameworkMethod frameworkMethod, Class> testClass) {
paramsFromMethodCommon = new ParamsFromMethodCommon(frameworkMethod);
this.testClass = testClass;
annotation = frameworkMethod.getAnnotation(Parameters.class);
}
@Override
public Object[] getParameters() {
return paramsFromMethodCommon.paramsFromMethod(testClass);
}
@Override
public boolean isApplicable() {
return annotation != null
&& annotation.source().isAssignableFrom(NullType.class)
&& (!annotation.method().isEmpty() || paramsFromMethodCommon.containsDefaultParametersProvidingMethod(testClass));
}
}