KeyStoreSecretProvider implements SecretProvider { @Override public String getUsername() { return new String(this.ksh.get(ALIAS_USERNAME) .orElseThrow(() -> new IllegalStateException("Username not present in KeyStore."))); } KeyStoreSecretProvider(final KeyStoreHandler ksh); @Override char[] getPassword(); @Override String getUsername(); @Override Optional<ZonkyApiToken> getToken(); @Override boolean setToken(ZonkyApiToken apiToken); boolean setPassword(final char[] password); boolean setUsername(final String username); @Override boolean isPersistent();  }
@Test void usernameNotSet() { assertThatThrownBy(() -> newMockProvider().getUsername()) .isInstanceOf(IllegalStateException.class); }