org.testng.internal.reflect.DataProviderMethodMatcher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of testng Show documentation
Show all versions of testng Show documentation
Testing framework for Java
package org.testng.internal.reflect;
import org.testng.internal.ThreeStateBoolean;
import static org.testng.internal.ThreeStateBoolean.FALSE;
import static org.testng.internal.ThreeStateBoolean.TRUE;
/**
* Checks the conformance as per data-provide specifications.
*
* @author Nitin Verma
*/
public class DataProviderMethodMatcher extends AbstractMethodMatcher {
private final DirectMethodMatcher directMethodMatcher;
private final ArrayEndingMethodMatcher arrayEndingMethodMatcher;
private MethodMatcher matchingMatcher = null;
public DataProviderMethodMatcher(final MethodMatcherContext context) {
super(context);
this.directMethodMatcher = new DirectMethodMatcher(context);
this.arrayEndingMethodMatcher = new ArrayEndingMethodMatcher(context);
}
/**
* {@inheritDoc}
*/
@Override
protected boolean hasConformance() {
boolean matching = false;
if (directMethodMatcher.conforms()) {
matching = true;
matchingMatcher = directMethodMatcher;
} else if (arrayEndingMethodMatcher.conforms()) {
matching = true;
matchingMatcher = arrayEndingMethodMatcher;
}
return matching;
}
/**
* {@inheritDoc}
*/
@Override
public Object[] getConformingArguments() throws MethodMatcherException {
if (ThreeStateBoolean.NONE.equals(getConforms())) {
conforms();
}
if (matchingMatcher != null) {
return matchingMatcher.getConformingArguments();
}
throw new MethodMatcherException("Data provider mismatch", getContext().getMethod(), getContext().getArguments());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy