com.github.siwenyan.superglue.team.TeamFactory Maven / Gradle / Ivy
package com.github.siwenyan.superglue.team;
import com.github.siwenyan.common.ImmediateAbortException;
import com.github.siwenyan.web.LostBrowserException;
import cucumber.api.Scenario;
import java.lang.reflect.Constructor;
import java.util.Map;
public class TeamFactory {
public static TeamBase getTeam(Scenario scenario, Map pf) throws LostBrowserException {
try {
String teamClassName = pf.get("team");
Class teamClass = Class.forName(teamClassName);
Class> paramTypes[] = new Class>[]{Scenario.class, Map.class};
Constructor> constructor = teamClass.getDeclaredConstructor(paramTypes);
Object[] params = new Object[]{scenario, pf};
return (TeamBase) constructor.newInstance(params);
} catch (Exception e) {
throw new ImmediateAbortException(e.getMessage());
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy