commit 4af1d41e7b6af34e83e4631adfd8efdc3796b58d
Author:     Jan Galinski <jan.galin...@holisticon.de>
AuthorDate: Wed, 8 May 2013 16:45:40 +0200
Commit:     Jan Galinski <jan.galin...@holisticon.de>
CommitDate: Wed, 8 May 2013 16:45:40 +0200

    fixed assertThatStepsInstancesAre() so that the order of annotation entries 
or stepsClasses does not matter

diff --git 
a/jbehave-needle/src/test/java/org/jbehave/core/configuration/needle/NeedleAnnotationBuilderBehaviour.java
 
b/jbehave-needle/src/test/java/org/jbehave/core/configuration/needle/NeedleAnnotationBuilderBehaviour.java
index 63e2689..369892e 100644
--- 
a/jbehave-needle/src/test/java/org/jbehave/core/configuration/needle/NeedleAnnotationBuilderBehaviour.java
+++ 
b/jbehave-needle/src/test/java/org/jbehave/core/configuration/needle/NeedleAnnotationBuilderBehaviour.java
@@ -2,9 +2,9 @@ package org.jbehave.core.configuration.needle;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.hasItems;
 import static org.hamcrest.Matchers.instanceOf;
 import static org.hamcrest.Matchers.is;
+import static org.hamcrest.collection.IsCollectionContaining.hasItems;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
@@ -13,7 +13,9 @@ import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 import org.jbehave.core.annotations.Configure;
 import org.jbehave.core.annotations.UsingSteps;
@@ -184,16 +186,17 @@ public class NeedleAnnotationBuilderBehaviour {
                assertThat((String) getter.getValue(), is(ValueGetter.VALUE));
        }
 
-    // TODO currently this method depends on order of elements in annotation
-    // FIXME provide sorting of array
        private void assertThatStepsInstancesAre(
                        final List<CandidateSteps> candidateSteps,
                        final Class<?>... stepsClasses) {
                assertThat(candidateSteps.size(), equalTo(stepsClasses.length));
-       for (int i = 0; i < stepsClasses.length; i++) {
-           assertThat(((Steps) candidateSteps.get(i)).instance(),
-                   instanceOf(stepsClasses[i]));
+
+               // transform candidateSteps to Set of classes
+               final Set<Class<?>> candidateStepClasses = new 
HashSet<Class<?>>();
+               for (final CandidateSteps step : candidateSteps) {
+                       candidateStepClasses.add(((Steps) 
step).instance().getClass());
                }
+               assertThat(candidateStepClasses, hasItems(stepsClasses));
        }
 
        @Configure()



Reply via email to