Home | History | Annotate | Download | only in parameters
      1 package junitparams.internal.parameters;
      2 
      3 import org.junit.runners.model.FrameworkMethod;
      4 
      5 import junitparams.Parameters;
      6 
      7 class ParametersFromTestClassMethod implements ParametrizationStrategy {
      8     private ParamsFromMethodCommon paramsFromMethodCommon;
      9     private Class<?> testClass;
     10     private Parameters annotation;
     11 
     12     ParametersFromTestClassMethod(FrameworkMethod frameworkMethod, Class<?> testClass) {
     13         paramsFromMethodCommon = new ParamsFromMethodCommon(frameworkMethod);
     14         this.testClass = testClass;
     15         annotation = frameworkMethod.getAnnotation(Parameters.class);
     16     }
     17 
     18     @Override
     19     public Object[] getParameters() {
     20         return paramsFromMethodCommon.paramsFromMethod(testClass);
     21     }
     22 
     23     @Override
     24     public boolean isApplicable() {
     25         return annotation != null
     26                && annotation.source().isAssignableFrom(Void.class)
     27                && (!annotation.method().isEmpty() || paramsFromMethodCommon.containsDefaultParametersProvidingMethod(testClass));
     28     }
     29 }
     30