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

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

There is a newer version: 1.1.1
Show newest version
package junitparams.internal.parameters;

import org.junit.runners.model.FrameworkMethod;

import junitparams.NullType;
import junitparams.Parameters;

class ParametersFromExternalClassMethod implements ParametrizationStrategy {
    private ParamsFromMethodCommon paramsFromMethodCommon;
    private Parameters annotation;

    ParametersFromExternalClassMethod(FrameworkMethod frameworkMethod) {
        this.paramsFromMethodCommon = new ParamsFromMethodCommon(frameworkMethod);
        annotation = frameworkMethod.getAnnotation(Parameters.class);
    }

    @Override
    public Object[] getParameters() {
        Class sourceClass = annotation.source();
        return !annotation.method().isEmpty()
            ? paramsFromMethodCommon.paramsFromMethod(sourceClass)
            : paramsFromMethodCommon.paramsFromNamedMethod(sourceClass);
    }

    @Override
    public boolean isApplicable() {
        return annotation != null
                && !annotation.source().isAssignableFrom(NullType.class)
                && (!annotation.method().isEmpty() || ! annotation.named().isEmpty());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy