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