title: Can I use mockito to match an object with an auto updated timestamp?
body: <p>What would be the best way to something like this where a timestamp is updated automatically before making the mocked call?</p>
  
  <p>Here is some dummy code of what I am trying to test:</p>
  
  <pre><code>public class ThingWithATimestamp {
      public Long timestamp;
      public String name;
  
      public ThingWithATimestamp(String name) {
          this.name = name;
      }
  }
  
  public class TheClassThatDoesStuff {
      private ThingConnector connector;
  
      public TheClassThatDoesStuff(ThingConnector connector) {
          this.connector = connector;
      }
  
      public void updateTheThing(MyThingWithATimestamp thing) {
          thing.timestamp = currentTimestamp();
          connector.update(thing);            
      }
  }
  </code></pre>
  
  <p>Here is what I want to test:</p>
  
  <pre><code>public class TheClassThatDoesStuffTests {
      @Test
      public void canUpdateTheThing() {
          ThingConnector connector = mock(ThingConnector.class);
          TheClassThatDoesStuff doer = new ThisClassThatDoesStuff(connector);
  
          doer.updateTheThing(new ThingWithATimestamp("the name"));
  
          verify(connector, times(1)).update(SomeMatcherThatICantFigureOut);
      }
  </code></pre>
  
  <p>I know this code is pretty dumbed down but I think it accurately portrays what I am trying to verify.  I basically need a matcher to fill in the test to verify that the timestamp is within X of the current time so I know it got updated correctly and that <code>connector.update</code> was called with the proper timestamp for the object.</p>