EventHelper { public AccessibilityNodeInfo claimLastSource() { return swapper.swap(null); } EventHelper(ThreadSafeSwapper<AccessibilityNodeInfo> swapper); void recordEvent(AccessibilityNodeInfo source); AccessibilityNodeInfo claimLastSource(); boolean restoreLastSource(AccessibilityNodeInfo previousSource);  }
@Test public void claimLastSourceReturnsExpectedNodeInfo() { when(mockSwapper.swap(null)).thenReturn(mockNodeInfo); AccessibilityNodeInfo actualResponse = testSubject.claimLastSource(); Assert.assertEquals(mockNodeInfo, actualResponse); }
@Test public void claimLastSourceCallsSwapWithNullObjectOnlyOnce() { testSubject.claimLastSource(); verify(mockSwapper, times(1)).swap(null); }