Repository: assertj/assertj

Problem statement:
IterableAssert should override isSameAs and isNotSameAs to unroll the actual instance.
#### Summary

IterableAssert  does not override the methods to unroll the actual instance.
#### Real life use case or example

```
@Test
public void testIterator() {
    Iterator<String> iterator = new ArrayList<String>().iterator();
    assertThat(iterator).isSameAs(iterator);
}
```

leads to: 
java.lang.AssertionError: 
Expecting:
 <java.util.ArrayList$Itr@a4300e>
and actual:
 <[]>
to refer to the same object
    at TestIterator.testIterator(TestIterator.java:xx)
#### Java 8 specific ?

NO 

The PR addressing this issue if any must be based on the `master` if the issue Java 8 specific, use otherwise the `2.x` branch.



Hints:

Patch:
diff --git a/src/main/java/org/assertj/core/api/IterableAssert.java b/src/main/java/org/assertj/core/api/IterableAssert.java
--- a/src/main/java/org/assertj/core/api/IterableAssert.java
+++ b/src/main/java/org/assertj/core/api/IterableAssert.java
@@ -120,6 +120,24 @@ public IterableAssert<T> isNotExactlyInstanceOf(Class<?> type) {
     }
     return super.isNotExactlyInstanceOf(type);
   }
+  
+  @Override
+  public IterableAssert<T> isSameAs(Object expected) {
+    if (actual instanceof LazyIterable) {
+      objects.assertSame(info, asLazyIterable().iterator, expected);
+      return myself;
+    }
+    return super.isSameAs(expected);
+  }
+  
+  @Override
+  public IterableAssert<T> isNotSameAs(Object expected) {
+    if (actual instanceof LazyIterable) {
+      objects.assertNotSame(info, asLazyIterable().iterator, expected);
+      return myself;
+    }
+    return super.isNotSameAs(expected);
+  }
 
   @SuppressWarnings("rawtypes")
   private LazyIterable asLazyIterable() {


Test patch:
diff --git a/src/test/java/org/assertj/core/api/Assertions_assertThat_with_Iterator_Test.java b/src/test/java/org/assertj/core/api/Assertions_assertThat_with_Iterator_Test.java
--- a/src/test/java/org/assertj/core/api/Assertions_assertThat_with_Iterator_Test.java
+++ b/src/test/java/org/assertj/core/api/Assertions_assertThat_with_Iterator_Test.java
@@ -14,6 +14,7 @@
 
 import static java.util.Arrays.asList;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
 import static org.assertj.core.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown;
 import static org.assertj.core.util.Sets.newLinkedHashSet;
 import static org.mockito.Mockito.mock;
@@ -128,6 +129,25 @@ public void isNotOfAnyClassIn_should_check_the_original_iterator() {
     assertThat(stringIterator).isNotOfAnyClassIn(LazyIterable.class, String.class);
   }
 
+  @Test
+  public void isSameAs_should_check_the_original_iterator_without_consuming_it() {
+    Iterator<?> iterator = mock(Iterator.class);
+    assertThat(iterator).isSameAs(iterator);
+    verifyZeroInteractions(iterator);
+  }
+  
+  @Test
+  public void isNotSameAs_should_check_the_original_iterator_without_consuming_it() {
+    Iterator<?> iterator = mock(Iterator.class);
+    try{
+      assertThat(iterator).isNotSameAs(iterator);
+    } catch(AssertionError e){
+      verifyZeroInteractions(iterator);
+      return;
+    }
+    Assertions.fail("Expected assertionError, because assert notSame on same iterator.");
+  }
+  
   @Test
   public void iterator_can_be_asserted_twice_even_though_it_can_be_iterated_only_once() {
     Iterator<String> names = asList("Luke", "Leia").iterator();