FallbackSecretProvider implements SecretProvider { @Override public synchronized boolean setToken(ZonkyApiToken apiToken) { this.token = apiToken; return true; } FallbackSecretProvider(final String username, final char... password); @Override char[] getPassword(); @Override String getUsername(); @Override synchronized Optional<ZonkyApiToken> getToken(); @Override synchronized boolean setToken(ZonkyApiToken apiToken); @Override boolean isPersistent();  }
@Test void setToken() { final SecretProvider p = SecretProvider.inMemory(FallbackSecretProviderTest.USR, FallbackSecretProviderTest.PWD.toCharArray()); assertThat(p.getToken()).isEmpty(); final ZonkyApiToken token = new ZonkyApiTokenImpl(UUID.randomUUID() .toString(), UUID.randomUUID() .toString(), 299); assertThat(p.setToken(token)).isTrue(); assertThat(p.getToken()).contains(token); }