
artoria.mock.SimpleMockProvider1 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of artoria-extend Show documentation
Show all versions of artoria-extend Show documentation
Artoria is a java technology framework based on the facade pattern.
The newest version!
package artoria.mock;
import artoria.util.ArrayUtils;
import artoria.util.StringUtils;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;
import static java.util.Collections.emptyMap;
public class SimpleMockProvider1 extends SimpleMockProvider {
protected Map parseFeatures(Object[] arguments) {
if (ArrayUtils.isEmpty(arguments)) { return emptyMap(); }
Map map = new HashMap();
for (Object feature : arguments) {
if (feature == null) { continue; }
if (feature instanceof ClassMockerConfig) {
ClassMockerConfig config = (ClassMockerConfig) feature;
Class> type = config.getType();
map.put(type, config);
}
}
return map;
}
@Override
protected Object mockClassData(Class> attrType, String attrName
, Object[] arguments, int nested, Class> originalType, Type... genericTypes) {
if (StringUtils.isNotBlank(attrName) && originalType != null) {
Map map = parseFeatures(arguments);
ClassMockerConfig config = map.get(originalType);
if (config!=null&&config.getMockerMap().get(attrName)!=null) {
Mocker mocker = config.getMockerMap().get(attrName);
return mocker.mock();
}
}
return super.mockClassData(attrType, attrName, arguments, nested, originalType, genericTypes);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy