@@ -298,22 +298,22 @@ public final Ordered containsAtLeastElementsIn(Iterable<?> expectedIterable) {
298
298
return failAtLeast (expected , missing );
299
299
}
300
300
301
- /*
302
- * TODO(cpovirk): In the NotInOrder case, also include a Fact that shows _only_ the required
303
- * elements (that is, without any extras) but in the order they were actually found. That should
304
- * make it easier for users to compare the actual order of the required elements to the expected
305
- * order. Or, if that's too much trouble, at least try to find a better title for the full
306
- * actual iterable than the default of "but was," which may _sound_ like it should show only the
307
- * required elements, rather than the full actual iterable.
308
- */
309
301
return ordered
310
302
? IN_ORDER
311
303
: new Ordered () {
312
304
@ Override
313
305
public void inOrder () {
314
- failWithActual (
315
- simpleFact ("required elements were all found, but order was wrong" ),
316
- fact ("expected order for required elements" , expected ));
306
+ ImmutableList .Builder <Fact > facts = ImmutableList .builder ();
307
+ facts .add (simpleFact ("required elements were all found, but order was wrong" ));
308
+ facts .add (fact ("expected order for required elements" , expected ));
309
+ List <Object > actualOrder = Lists .newArrayList (IterableSubject .this .actual );
310
+ if (actualOrder .retainAll (expected )) {
311
+ facts .add (fact ("but order was" , actualOrder ));
312
+ facts .add (fullContents ());
313
+ failWithoutActual (facts .build ());
314
+ } else {
315
+ failWithActual (facts .build ());
316
+ }
317
317
}
318
318
};
319
319
}
@@ -841,15 +841,19 @@ private void pairwiseCheck(String expectedFact, PairwiseChecker checker) {
841
841
}
842
842
}
843
843
844
- /** @deprecated You probably meant to call {@link #containsNoneOf} instead. */
844
+ /**
845
+ * @deprecated You probably meant to call {@link #containsNoneOf} instead.
846
+ */
845
847
@ Override
846
848
@ Deprecated
847
849
public void isNoneOf (
848
850
@ Nullable Object first , @ Nullable Object second , @ Nullable Object @ Nullable ... rest ) {
849
851
super .isNoneOf (first , second , rest );
850
852
}
851
853
852
- /** @deprecated You probably meant to call {@link #containsNoneIn} instead. */
854
+ /**
855
+ * @deprecated You probably meant to call {@link #containsNoneIn} instead.
856
+ */
853
857
@ Override
854
858
@ Deprecated
855
859
public void isNotIn (Iterable <?> iterable ) {
@@ -1955,8 +1959,7 @@ private final class Pairer {
1955
1959
* Returns a {@link Pairing} of the given expected and actual values, or {@code null} if the
1956
1960
* expected values are not uniquely keyed.
1957
1961
*/
1958
- @ Nullable
1959
- Pairing pair (
1962
+ @ Nullable Pairing pair (
1960
1963
List <? extends E > expectedValues ,
1961
1964
List <? extends A > actualValues ,
1962
1965
Correspondence .ExceptionStore exceptions ) {
0 commit comments