Title: [937] trunk/jbehave-core/src/java/org/jbehave/scenario/steps/Steps.java: Use configuration as member variable.
Revision
937
Author
mauro
Date
2008-09-21 10:43:42 -0500 (Sun, 21 Sep 2008)

Log Message

Use configuration as member variable.  

Modified Paths


Diff

Modified: trunk/jbehave-core/src/java/org/jbehave/scenario/steps/Steps.java (936 => 937)

--- trunk/jbehave-core/src/java/org/jbehave/scenario/steps/Steps.java	2008-09-21 11:15:18 UTC (rev 936)
+++ trunk/jbehave-core/src/java/org/jbehave/scenario/steps/Steps.java	2008-09-21 15:43:42 UTC (rev 937)
@@ -2,11 +2,11 @@
 
 import java.lang.reflect.Method;
 import java.util.ArrayList;
+import java.util.List;
 
 import org.jbehave.scenario.annotations.Given;
 import org.jbehave.scenario.annotations.Then;
 import org.jbehave.scenario.annotations.When;
-import org.jbehave.scenario.parser.StepPatternBuilder;
 
 /**
  * <p>
@@ -20,29 +20,33 @@
  * '$' prefix to pick up parameters.
  * </p>
  * <p>
- * For instance, you could define a method as: <code lang="java">
- * 
- * @When(&quot; I log in as $username with password: $password&quot;) public
- *                void logIn(String username, String password) { //... } </code>
- *                and this would match the step:
- *                <code>When I log in as Liz with password: Pa55word</code>
- *                <p>
- *                When the step is perfomed, the parameters in the scenario
- *                definition will be passed to the class, so in this case the
- *                effect will be <code>mySteps.logIn("Liz", "Pa55word");</code>
- *                </p>
- *                <p>
- *                ParameterConverters can be used to convert parameters from any
- *                String format to another class. Custom converters can be
- *                provided here in addition to the defaults.
- *                </p>
+ * For instance, you could define a method as: 
+ * <pre>
+ * <code lang="java"> 
+ * @When("I log in as $username with password: $password") <br/> 
+ * public void logIn(String username, String password) { //... } 
+ * </code>
+ * </pre>
+ * and this would match the step:
+ * <pre>
+ * When I log in as Liz with password: Pa55word
+ * </pre>
+ * </p>
+ * <p>When the step is perfomed, the parameters in the scenario
+ * definition will be passed to the class, so in this case the
+ * effect will be
+ * <pre>
+ * mySteps.logIn(&quot;Liz&quot;, &quot;Pa55word&quot;);
+ * </pre>
+ * </p>
+ * <p>
+ * StepsConfiguration can be used to provide customization to the defaults configuration
+ * elements, eg custom parameters converters. 
+ * </p>
  */
 public class Steps {
 
-    private final StepPatternBuilder patternBuilder;
-    private final StepMonitor stepMonitor;
-    private final ParameterConverters parameterConverters;
-    private final String[] startingWords;
+    private final StepsConfiguration configuration;
 
     /**
      * Creates Steps with default configuration
@@ -68,17 +72,14 @@
      * @param configuration the StepsConfiguration
      */
     public Steps(StepsConfiguration configuration) {
-        this.patternBuilder = configuration.getPatternBuilder();
-        this.stepMonitor = configuration.getMonitor();
-        this.parameterConverters = configuration.getParameterConverters();
-        this.startingWords = configuration.getStartingWords();
+        this.configuration = configuration;
     }
 
     /**
      * @return all the steps that can be performed by this class
      */
     public CandidateStep[] getSteps() {
-        ArrayList<CandidateStep> steps = new ArrayList<CandidateStep>();
+        List<CandidateStep> steps = new ArrayList<CandidateStep>();
         for (Method method : this.getClass().getMethods()) {
             if (method.isAnnotationPresent(Given.class)) {
                 createCandidateStep(steps, method, method.getAnnotation(Given.class).value());
@@ -93,8 +94,8 @@
         return steps.toArray(new CandidateStep[steps.size()]);
     }
 
-    private void createCandidateStep(ArrayList<CandidateStep> steps, Method method, String stepAsString) {
-        steps.add(new CandidateStep(stepAsString, method, this, patternBuilder, stepMonitor, parameterConverters,
-                startingWords));
+    private void createCandidateStep(List<CandidateStep> steps, Method method, String stepAsString) {
+        steps.add(new CandidateStep(stepAsString, method, this, configuration.getPatternBuilder(), configuration
+                .getMonitor(), configuration.getParameterConverters(), configuration.getStartingWords()));
     }
 }


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to