title: Comparing two observableLists in Junit
body: <p>I've tried to check whether two lists are the same using assertEquals and this works just fine but when tried to change the lists to observableList, the test failed.</p>
  
  <p>So how can I compare two observable lists in JUnit? I would like to compare only the content of the lists. Basically, these observableLists contain Point objects and in the Point class I've got hashCodeBuilder and equalsBuilder methods. The <code>hashCode()</code> and <code>equals()</code> methods were needed for the list comparison but I'm not sure whether they are needed for the ObservableList.</p>
  
  <pre><code>public class TestClass {
      private MyClass myclass;
      ObservableList&lt;Point&gt; TestPoints = FXCollections.observableArrayList();
  
      /**
       * @throws java.lang.Exception
       */
      @Before
      public void setUp() throws Exception {
          myclass = new MyClass();
  
          TestPoints.add(new Point(300.0,200.0));
          TestPoints.add(new Point(600.0,500.0));
          TestPoints.add(new Point(100.0,100.0));
          TestPoints.add(new Point(200.0,200.0));
          TestPoints.add(new Point(100.0,500.0));
          TestPoints.add(new Point(600.0,100.0));
      }
  
      @Test
      public void testClass() {
          ObservableList&lt;Point&gt; expectedResult = FXCollections.observableArrayList();
          expectedResult.add(new Point(100.0,100.0));
          expectedResult.add(new Point(100.0,500.0));
          expectedResult.add(new Point(600.0,500.0));
          expectedResult.add(new Point(600.0,100.0));
  
          ObservableList&lt;Point&gt; actualResult = FXCollections.observableArrayList();
          actualResult = myclass.giftWrapping(TestPoints);
  
          assertEquals(expectedResult, actualResult);
      }
  </code></pre>
  
  <p>This is the point class</p>
  
  <pre><code>public class Point {
  
      private final DoubleProperty x;
      private final DoubleProperty y;
  
      public Point() {
          this(0, 0);
      }
  
      public Point(double x, double y) {
          this.x = new SimpleDoubleProperty(x);
          this.y = new SimpleDoubleProperty(y);
      }
  @Override
  public int hashCode() {
      HashCodeBuilder hashCodeBuilder = new HashCodeBuilder();
      hashCodeBuilder.append(x);
      hashCodeBuilder.append(y);
      return hashCodeBuilder.toHashCode();
  }
  
  @Override
  public boolean equals(Object obj) {
      if (this == obj) {
          return true;
      }
      if (obj == null) {
          return false;
      }
      if (!(obj instanceof Point)) {
          return false;
      }
      Point other = (Point) obj;
      EqualsBuilder equalsBuilder = new EqualsBuilder();
      equalsBuilder.append(x, other.x);
      equalsBuilder.append(y, other.y);
      return equalsBuilder.isEquals();
  }
  </code></pre>
  
  <p>This would work if i used a List but doesn't not work if i Used an observableList</p>