All Downloads are FREE. Search and download functionalities are using the official Maven repository.

junitparams.internal.parameters.ParametersFromTestClassMethod Maven / Gradle / Ivy

There is a newer version: 1.1.1
Show newest version
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));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy