@Test public void should_process_person_within_specified_time() { systemUnderTest.process(new Person()); verify(personSaver, timeout(1000)).savePerson(any(Person.class)); }
public void process(final Person person) { new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(500); } catch (InterruptedException e) { System.err.printf("The thread got interrupted [%s]%n", e); } personSaver.savePerson(person); } }).start(); }
PersonProcessor { public void process(final Person person) { new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(500); } catch (InterruptedException e) { System.err.printf("The thread got interrupted [%s]%n", e); } personSaver.savePerson(person); } }).start(); } }
PersonProcessor { public void process(final Person person) { new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(500); } catch (InterruptedException e) { System.err.printf("The thread got interrupted [%s]%n", e); } personSaver.savePerson(person); } }).start(); } PersonProcessor(PersonSaver personSaver); }
PersonProcessor { public void process(final Person person) { new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(500); } catch (InterruptedException e) { System.err.printf("The thread got interrupted [%s]%n", e); } personSaver.savePerson(person); } }).start(); } PersonProcessor(PersonSaver personSaver); void process(final Person person); }
PersonProcessor { public void process(final Person person) { new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(500); } catch (InterruptedException e) { System.err.printf("The thread got interrupted [%s]%n", e); } personSaver.savePerson(person); } }).start(); } PersonProcessor(PersonSaver personSaver); void process(final Person person);  }