commit c107eea86c40ce4d2b327a2f873e923e306861b3
Author:     Mauro Talevi <mauro.tal...@aquilonia.org>
AuthorDate: Sun, 26 May 2013 13:23:47 +0200
Commit:     Mauro Talevi <mauro.tal...@aquilonia.org>
CommitDate: Sun, 26 May 2013 13:23:47 +0200

    JBEHAVE-917:  Allow generic lists.

diff --git 
a/jbehave-core/src/main/java/org/jbehave/core/steps/InstanceStepsFactory.java 
b/jbehave-core/src/main/java/org/jbehave/core/steps/InstanceStepsFactory.java
index 890de56..1c3877a 100755
--- 
a/jbehave-core/src/main/java/org/jbehave/core/steps/InstanceStepsFactory.java
+++ 
b/jbehave-core/src/main/java/org/jbehave/core/steps/InstanceStepsFactory.java
@@ -20,7 +20,7 @@ public class InstanceStepsFactory extends 
AbstractStepsFactory {
         this(configuration, asList(stepsInstances));
     }
 
-    public InstanceStepsFactory(Configuration configuration, List<Object> 
stepsInstances) {
+    public InstanceStepsFactory(Configuration configuration, List<?> 
stepsInstances) {
         super(configuration);
         for (Object instance : stepsInstances) {
             this.stepsInstances.put(instance.getClass(), instance);
diff --git 
a/jbehave-core/src/test/java/org/jbehave/core/steps/InstanceStepsFactoryBehaviour.java
 
b/jbehave-core/src/test/java/org/jbehave/core/steps/InstanceStepsFactoryBehaviour.java
index 8dee8eb..3fc8fc0 100755
--- 
a/jbehave-core/src/test/java/org/jbehave/core/steps/InstanceStepsFactoryBehaviour.java
+++ 
b/jbehave-core/src/test/java/org/jbehave/core/steps/InstanceStepsFactoryBehaviour.java
@@ -5,6 +5,7 @@ import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.instanceOf;
 import static org.hamcrest.Matchers.is;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import org.jbehave.core.annotations.AsParameterConverter;
@@ -33,6 +34,28 @@ public class InstanceStepsFactoryBehaviour {
         assertThat(factory.hasAnnotatedMethods(NoAnnotatedMethods.class), 
is(false));
     } 
 
+       @Test
+       public void shouldAllowGenericList() {
+               List<? super MyInterface> list = new ArrayList<MyInterface>();
+               list.add(new MyStepsAWithInterface());
+               list.add(new MyStepsBWithInterface());
+               InstanceStepsFactory factory = new InstanceStepsFactory(
+                       new MostUsefulConfiguration(), list);
+               List<CandidateSteps> candidateSteps = 
factory.createCandidateSteps();           
+               assertThat(candidateSteps.size(), equalTo(2));
+
+       }
+
+       static interface MyInterface {
+
+       }
+
+       static class MyStepsAWithInterface implements MyInterface {
+       }
+
+       static class MyStepsBWithInterface implements MyInterface {
+       }
+
     static class MySteps  {
 
         @Given("foo named $name")



Reply via email to