default TOKEN refreshSingle(TOKEN token) throws InterruptedException { return token == null ? null : Iterables.getOnlyElement(refresh(ImmutableSet.of(token)), null); } }
@Override public Set<String> refresh(Set<String> strings) throws InterruptedException { return delegate.refresh(strings); } }
@Test public void refreshSingleCallsRefreshWithMatchingArgument() throws InterruptedException { client.refreshSingle(LOCK_TOKEN); verify(mockClient).refresh(eq(ImmutableSet.of(LOCK_TOKEN))); }
@Test public void refreshSingleDoesNotCallRefreshWithNull() throws InterruptedException { client.refreshSingle(null); verify(mockClient, never()).refresh(any()); }
@Test public void refreshSingleReturnsNullIfCannotRefresh() throws InterruptedException { when(mockClient.refresh(any())).thenReturn(ImmutableSet.of()); assertThat(client.refreshSingle(LOCK_TOKEN), nullValue()); }
@Test public void refreshSingleReturnsTokenIfCanBeRefreshed() throws InterruptedException { when(mockClient.refresh(any())).then(REPLY_WITH_FIRST_TOKEN); assertEquals(client.refreshSingle(LOCK_TOKEN), LOCK_TOKEN); }