AutomatorAction { void perform(UiSelector selector, UiObject object) { try { wrappedPerform(selector, object); } catch (UiObjectNotFoundException e) { throw new RuntimeException(e); } }  static AutomatorAction click(); static AutomatorAction check(final boolean check); static AutomatorAction setText(final String text); static AutomatorAction clearTextField(); static AutomatorAction swipeRight(final int steps); static AutomatorAction swipeLeft(final int steps); static AutomatorAction scrollTextIntoView(final String text); abstract void wrappedPerform(UiSelector selector, UiObject object);  }
@Test(timeout = 1000) public void perform() throws InterruptedException { final UiSelector expectedSelector = mock(UiSelector.class); final UiObject expectedObject = mock(UiObject.class); final CountDownLatch latch = new CountDownLatch(1); AutomatorAction action = new AutomatorAction() { @Override public void wrappedPerform(UiSelector selector, UiObject object) throws UiObjectNotFoundException { assertEquals(expectedSelector, selector); assertEquals(expectedObject, object); latch.countDown(); } }; action.perform(expectedSelector, expectedObject); latch.await(); }