org.itest.util.generator.ITestObjectGeneratorUtil Maven / Gradle / Ivy
package org.itest.util.generator;
import org.itest.ITestConfig;
import org.itest.ITestConstants;
import org.itest.impl.ITestContextImpl;
import org.itest.impl.ITestParamAssignmentImpl;
import org.itest.param.ITestParamAssignment;
import org.itest.param.ITestParamState;
import java.util.Collections;
public class ITestObjectGeneratorUtil {
public static T generateObject(Class clazz, ITestConfig iTestConfig, ITestObjectDefinition... definitions) {
T res;
ITestParamAssignment[] iTestParamAssignments = new ITestParamAssignment[definitions.length];
for (int i = 0; i < definitions.length; i++) {
ITestParamState params = iTestConfig.getITestParamLoader().loadITestParam(definitions[i].getClazz(), definitions[i].getUse());
iTestParamAssignments[i] = new ITestParamAssignmentImpl(definitions[i].getTransform(), params);
}
ITestParamState merged = iTestConfig.getITestParamsMerger().merge(iTestParamAssignments).getElement(ITestConstants.THIS);
res = (T) iTestConfig.getITestObjectGenerator().generate(clazz, merged, new ITestContextImpl(merged, Collections.EMPTY_MAP));
return res;
}
}