title: Java 8: unit-testing a method that returns a Function object
body: <p>I'm trying to write a Java 8 unit test for a method that returns a <code>Function</code>; something like:</p>
  
  <pre><code>class MyObject&lt;X&gt; {
       public Function&lt;X,Obj&gt; getFunction() {...}
   }
  </code></pre>
  
  <p>In my unit test I create a sample Object and call <code>getFunction()</code> and want to compare that to the expected function which does not work with <code>org.junit.Assert.assertEquals</code>:</p>
  
  <pre><code>@Test
  public void getFunction_returnsFunction() {
     final MyObject&lt;St&gt; object = new MyObject&lt;&gt;(..);
     final Function&lt;St,Obj&gt; expectedResult = ...;
  
     // this does not work
     assertEquals(expectedResult, object.getFunction());
  }
  </code></pre>
  
  <p>Is it even possible to compare two <code>Function</code>s? How would you recommend to unit test this method?</p>