| 1 | |
package org.jbehave.core.steps.scala; |
| 2 | |
|
| 3 | |
import java.util.ArrayList; |
| 4 | |
import java.util.List; |
| 5 | |
|
| 6 | |
import org.jbehave.core.configuration.Configuration; |
| 7 | |
import org.jbehave.core.configuration.scala.ScalaContext; |
| 8 | |
import org.jbehave.core.steps.AbstractStepsFactory; |
| 9 | |
|
| 10 | |
public class ScalaStepsFactory extends AbstractStepsFactory { |
| 11 | |
|
| 12 | |
private final ScalaContext context; |
| 13 | |
|
| 14 | |
public ScalaStepsFactory(Configuration configuration, ScalaContext context){ |
| 15 | 2 | super(configuration); |
| 16 | 2 | this.context = context; |
| 17 | 2 | } |
| 18 | |
|
| 19 | |
@Override |
| 20 | |
protected List<Class<?>> stepsTypes() { |
| 21 | 1 | List<Class<?>> types = new ArrayList<Class<?>>(); |
| 22 | 1 | for (Object object : context.getInstances() ){ |
| 23 | 2 | if (hasAnnotatedMethods(object.getClass())) { |
| 24 | 1 | types.add(object.getClass()); |
| 25 | |
} |
| 26 | 2 | } |
| 27 | 1 | return types; |
| 28 | |
} |
| 29 | |
|
| 30 | |
public Object createInstanceOfType(Class<?> type) { |
| 31 | 2 | return context.getInstanceOfType(type); |
| 32 | |
} |
| 33 | |
|
| 34 | |
} |