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

org.itest.util.generator.ITestObjectGeneratorUtil Maven / Gradle / Ivy

There is a newer version: 1.5.4
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy