title: Mockito 1.9: format the expected value (like "actual formatter" in custom ArgumentMatcher)
body: <p>In Mockito 1.9.5 I'd like to format the <em>actual</em> value when <code>verify</code>ing the (in order) call arguments of a method.</p>
  
  <p>Mockito provides a overridable <code>describeTo</code> method within <code>ArcgumentMatcher&lt;T&gt;</code>s that enables me to format the <em>expected</em> value.
  When mocking JRE classes like <code>DatagramPacket</code> using PowerMockito's <code>whenNew</code>, the <em>actual</em> value is not formatted the way I like.</p>
  
  <p>In the following example I'm only interested if the address of the <code>DatagramPacket</code> was called in order. If not, I'd like to see the mismatching, actual value and not the default <code>toString()</code> name "<code>java.net.DatagramPacket@7546a399</code>".</p>
  
  <p>My custom matcher is able to match only the <code>InetSocketAddress</code>.</p>
  
  <h2>Example</h2>
  
  <p><strong>The custom matcher:</strong></p>
  
  <pre><code>static class IsDatagramForAddress extends ArgumentMatcher&lt;DatagramPacket&gt; {
      final InetSocketAddress addr;
  
      public IsDatagramForAddress(InetSocketAddress addr){
          this.addr = addr;
      }
  
      public boolean matches(Object dgp) {
          SocketAddress isa = ((DatagramPacket) dgp).getSocketAddress();
          boolean eq = isa.equals(addr);
  
          // System.out.println(dgp + ": " + isa + "&lt; &gt;" + addr + " == " + eq);
  
          return eq;
      }
  
      @Override
      public void describeTo(Description description) {
          description.appendText(addr == null ? null : addr.toString());
      }
  }
  </code></pre>
  
  <p><strong>The test:</strong></p>
  
  <pre><code>private static DatagramPacket isDatagramForAddress(InetSocketAddress addr){
      return argThat(new IsDatagramForAddress(addr));
  }
  
  ...
  
  @Test
  public void testSendIsCalledWithServersInOrder() throws Exception {
  
      InOrder order = inOrder(sock);
  
      order.verify(sock).send(isDatagramForAddress(new InetSocketAddress("8.8.8.2", 100)));
      order.verify(sock).send(isDatagramForAddress(new InetSocketAddress("8.8.8.1", 100)));
  }
  </code></pre>
  
  <p><strong>This is what I get:</strong></p>
  
  <pre><code>org.mockito.exceptions.verification.VerificationInOrderFailure:
  Verification in order failure
  Wanted but not invoked:
  datagramSocket.send(/8.8.8.1:100);
  -&gt; at xxxx.XxxxTest.testSendIsCalledWithServersInOrder(XxxxTest.java:95)
  Wanted anywhere AFTER following interaction:
  datagramSocket.send(
      java.net.DatagramPacket@7546a399
  );
  -&gt; at xxxx.XxxxTest.testSendIsCalledWithServersInOrder(XxxxTest.java:90)
  
      at xxxx.XxxxTest.testSendIsCalledWithServersInOrder(XxxxTest.java:95)
      ...
  </code></pre>
  
  <p><strong>This is what I expect:</strong></p>
  
  <pre><code>org.mockito.exceptions.verification.VerificationInOrderFailure:
  Verification in order failure
  Wanted but not invoked:
  datagramSocket.send(/8.8.8.1:100);
  -&gt; at xxxx.XxxxTest.testSendIsCalledWithServersInOrder(XxxxTest.java:95)
  Wanted anywhere AFTER following interaction:
  datagramSocket.send(/8.8.8.2:100);
  -&gt; at xxxx.XxxxTest.testSendIsCalledWithServersInOrder(XxxxTest.java:90)
  
      at xxxx.XxxxTest.testSendIsCalledWithServersInOrder(XxxxTest.java:95)
      ...
  </code></pre>
  
  <h2>Question boiled down</h2>
  
  <p>How can I format/<code>toString()</code> the <em>actual</em> value?</p>