1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2025-09-14 20:59:39 +02:00

Modified Passphrase.fromPassword() to apply null value to be much clearer for Kotlin. Added a test for that.

This commit is contained in:
DenBond7 2021-04-08 13:04:13 +03:00
parent cd19f91d77
commit e77e97bc08
No known key found for this signature in database
GPG key ID: F74FC4E6441BA8C3
2 changed files with 10 additions and 3 deletions

View file

@ -37,11 +37,11 @@ public class Passphrase {
/**
* Create a {@link Passphrase} from a {@link String}.
*
* @param password password
* @param password password that may be null
* @return passphrase
*/
public static Passphrase fromPassword(String password) {
return new Passphrase(password.toCharArray());
public static Passphrase fromPassword(@Nullable String password) {
return new Passphrase(password == null ? null : password.toCharArray());
}
/**

View file

@ -37,4 +37,11 @@ public class PassphraseTest {
assertFalse(passphrase.isValid());
assertThrows(IllegalStateException.class, passphrase::getChars);
}
@Test
public void testFromPasswordNull() {
Passphrase passphrase = Passphrase.fromPassword(null);
assertArrayEquals(null, passphrase.getChars());
assertTrue(passphrase.isValid());
}
}