net.serenitybdd.core.steps.Instrumented Maven / Gradle / Ivy
package net.serenitybdd.core.steps;
import net.thucydides.core.steps.StepFactory;
public class Instrumented {
private static StepFactory stepFactory = new StepFactory();
public static InstrumentedBuilder instanceOf(Class instanceClass) {
return new InstrumentedBuilder(instanceClass);
}
public static class InstrumentedBuilder {
private final Class instanceClass;
private final Object[] constructorParameters;
public InstrumentedBuilder(Class instanceClass) {
this(instanceClass, new Object[]{});
}
public InstrumentedBuilder(Class instanceClass, Object[] constructorParameters) {
this.instanceClass = instanceClass;
this.constructorParameters = constructorParameters;
}
public T newInstance() {
return stepFactory.getUniqueStepLibraryFor(instanceClass, constructorParameters);
}
public T withProperties(Object... constructorParameters) {
return new InstrumentedBuilder(instanceClass, constructorParameters).newInstance();
}
}
}