private static <T>void assertListsEqualInOrder(String message,String expectedLabel,List<T> expected,String actualLabel,List<T> actual){
  int i=0;
  for (; i < expected.size() && i < actual.size(); ++i) {
    if (!Objects.equals(expected.get(i),actual.get(i))) {
      Assert.fail(String.format("%s: %s and %s have %d items in common and then differ. " + "Item in %s (%d more): %s, item in %s (%d more): %s",message,expectedLabel,actualLabel,i,expectedLabel,expected.size() - i - 1,expected.get(i),actualLabel,actual.size() - i - 1,actual.get(i)));
    }
  }
  if (i < expected.size()) {
    Assert.fail(String.format("%s: %s has %d more items after matching all %d from %s. First 5: %s",message,expectedLabel,expected.size() - actual.size(),actual.size(),actualLabel,expected.subList(actual.size(),Math.min(expected.size(),actual.size() + 5))));
  }
 else   if (i < actual.size()) {
    Assert.fail(String.format("%s: %s has %d more items after matching all %d from %s. First 5: %s",message,actualLabel,actual.size() - expected.size(),expected.size(),expectedLabel,actual.subList(expected.size(),Math.min(actual.size(),expected.size() + 5))));
  }
 else {
  }
}

private static < T > void assertListsEqualInOrder ( String message , String expectedLabel , List < T > expected , String actualLabel , List < T > actual ) { int i = 0 ; for ( ; i < expected . size ( ) && i < actual . size ( ) ; ++ i ) { if ( ! Objects . equals ( expected . get ( i ) , actual . get ( i ) ) ) { Assert . fail ( String . format ( "%s: %s and %s have %d items in common and then differ. " + "Item in %s (%d more): %s, item in %s (%d more): %s" , message , expectedLabel , actualLabel , i , expectedLabel , expected . size ( ) - i - 1 , expected . get ( i ) , actualLabel , actual . size ( ) - i - 1 , actual . get ( i ) ) ) ; } } if ( i < expected . size ( ) ) { Assert . fail ( String . format ( "%s: %s has %d more items after matching all %d from %s. First 5: %s" , message , expectedLabel , expected . size ( ) - actual . size ( ) , actual . size ( ) , actualLabel , expected . subList ( actual . size ( ) , Math . min ( expected . size ( ) , actual . size ( ) + 5 ) ) ) ) ; } else if ( i < actual . size ( ) ) { Assert . fail ( String . format ( "%s: %s has %d more items after matching all %d from %s. First 5: %s" , message , actualLabel , actual . size ( ) - expected . size ( ) , expected . size ( ) , expectedLabel , actual . subList ( expected . size ( ) , Math . min ( actual . size ( ) , expected . size ( ) + 5 ) ) ) ) ; } else { } }
compares two lists elementwise and throws a detailed assertion failure optimized for human reading in case they are unequal .
