com.griddynamics.qa.datapool.matchers.CountIsLessMatcher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of data-pool Show documentation
Show all versions of data-pool Show documentation
Test Data Pool tool is intended to mitigate risks of running automated tests against multiple unstable
“FullDB” environments having unpredictable set of data.
The newest version!
package com.griddynamics.qa.datapool.matchers;
import com.griddynamics.qa.datapool.datatype.IDataType;
import com.griddynamics.qa.datapool.matchers.aux.IComparableMatcher;
import com.griddynamics.qa.datapool.matchers.aux.RelationSign;
import java.util.Collection;
import java.util.function.Predicate;
/**
* @author Alexey Lyanguzov.
*/
class CountIsLessMatcher implements IComparableMatcher {
@Override @SuppressWarnings("all")
public Predicate getMatcher(String propName, Object value) {
return (o) -> {
Object obj = o.get(propName, Object.class);
if(obj == null){
return true; // Questionable but needed to find empty collections
}
else if(Collection.class.isAssignableFrom(obj.getClass()) && Integer.class.isAssignableFrom(value.getClass())){
Collection collection = (Collection)obj;
return buildMatcher((Comparable)value, Integer.class, RelationSign.LESS_THAN).test((Comparable)collection.size());
}
return false; //Unknown comparison
};
}
}